Code Monkey home page Code Monkey logo

Comments (2)

thosakwe avatar thosakwe commented on June 12, 2024

Hm, I don't disagree.

  1. The only viable workaround I can think of is a custom auth hook. I will include one with the 1.0.0 release.

It might be similar to this:

// Clients can't interact with the `params` object, so the seeder could just stick `{seeder: true}` in there.
//
// The hook can then just delete `params.provider`, and bypass the auth filter.
function seedHook(hook) {
  if (hook.params.seeder === true)
    delete hook.params.provider;
  return hook;
}
  1. Ok, I see what you mean.
// Kinda tedious to this, but here's the nested service...
app.use('/users/:id/clients', (req, res, next) => {
    req.feathers.id = req.params.id;
    return next();
}, {
  get(id, params) {
    return new Promise((resolve, reject) => {
      db.collection('clients')
          .find({userId: new ObjectId(params.id)})
          .then((err, data) => {
              return err ? reject(err) : resolve({data});
          });
    });
  }
});

// Your seeder config needs to pass the user id to the client seeder, or else you can't seed...
// Which brings me to this idea:

const seederConfig = {
  path: 'users',
  // ...
  // If we pass the created context, along with the 'seed' function to a callback, then we can seed clients?
  callback(user, seed) {
    // Return Promise or synchronous computation, doesn't matter
    return seed({
      path: 'users/:id/clients',
      params: {id: user._id},
      template: {foo: 'bar'}
    });
  }
};

I need to add more tests to this library, regardless, so I'll make sure to add provisions for this. As it is, I haven't touched this codebase in months, because I was under the impression that nobody was using it.

Open for suggestions

from feathers-seeder.

thosakwe avatar thosakwe commented on June 12, 2024

The latest commit, 637ec86, should resolve this for you. :)

Check out this test.

from feathers-seeder.

Related Issues (19)

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.