Giter Club home page Giter Club logo

Comments (2)

dennisgl avatar dennisgl commented on June 17, 2024

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.

brandoncc avatar brandoncc commented on June 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.