Comments (2)
Not sure why you have a separated plugin to attach Session
service to ctx
(unrecommended), when your RPC handlers appear to have a direct dependency on Session
. Dependency system is also how Fusion.js ensuring the execution order of initializations of individual plugins and middlewares in a request cycle.
Please try the following, and feel free to re-open the task with more details if the issue persists:
// src/rpc/handlers.js
import {createPlugin} from 'fusion-core';
import {SessionToken} from 'fusion-tokens';
export default createPlugin({
deps: {Session: SessionToken},
provides: ({Session}) => {
return {
create: async ({title}, ctx) => {
try {
const session = Session.from(ctx);
let todos = JSON.parse(session.get('todos') || '[]');
console.log('LOADED');
console.log(session);
todos = [...todos, {id: nextId++, title, completed: false}];
session.set('todos', JSON.stringify(todos));
console.log('ADDED');
console.log(session);
return {todos};
} catch (e) {
console.log(e.message);
}
},
};
},
});
from fusion-plugin-jwt.
Hi @dennisgl, I didn't realize I hadn't closed this issue. Sorry about that. I ended up going with https://github.com/brandoncc/tofu-app/blob/master/src/plugins/todos.js Which is basically what you are talking about here. I opened this issue before I had a good understanding of how the plugin system worked. Sorry for wasting your time!
from fusion-plugin-jwt.
Related Issues (17)
- Add initial implementation
- Handle cookie expiration without throwing
- Parity between Koa-Session and Fusion's JWT Session
- Migrate fusion-plugin-jwt to DI
- provide way to not set cookie if not needed yet HOT 1
- Migrate fusion-plugin-jwt to createPlugin
- Add token exports
- Use Buildkite for CI
- Uncaught ReferenceError: process is not defined
- Reset cookie if signature is invalid HOT 1
- Migrate to new fusion-tokens api
- Add Token dependencies to readme
- Browser bundle has redundant code
- Update dependencies
- Fix flow types
- Fix flow types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fusion-plugin-jwt.