Coder Social home page Coder Social logo

A full example about epilogue HOT 9 CLOSED

dchester avatar dchester commented on June 17, 2024
A full example

from epilogue.

Comments (9)

mbroadst avatar mbroadst commented on June 17, 2024

Documentation is definitely on the roadmap here, and providing an example using the task list is a great idea. In the meantime, the test suite should provide a pretty good idea of how to set up sequelize + epilogue + express or restify. I've tried to make the tests as self-documenting as possible, hopefully you can get a head start there before a more comprehensive example is provided.

Take a look at:

from epilogue.

codebased avatar codebased commented on June 17, 2024

I have also started using epilogue. However, I am also struggling to start listening end points.

TypeError: Object User has no method 'find'
at Read.fetch (/ Documents/gits/tm/node_modules/epilogue/lib/Controllers/read.js:42:6)

from epilogue.

mbroadst avatar mbroadst commented on June 17, 2024

@shaneveeg were you able to figure out your problem? Would you perhaps be interesting in committing back what you learned as a tutorial here? @codebased I believe your case is simple enough to be covered by the "example" on the main page, you just have a typo (which we'll address in the other ticket).

Extending the sequelize example is incredibly easy, I just don't think I should go and copy the whole thing. Last night I included in the 0.3.3 release the ability to specify just a model to epilogue's resource factory method btw so now you can just do this (using their example):

if you had models/index.js (per the example), you could do:

var epilogue = require('epilogue'),
      models = require('./models'),
      resources = [];

Object.keys(models).forEach(function(modelName) {
    resources.push(epilogue.resource({ model: models[modelName] }));
});

This is a very simple case, but you might want to add a class method to your sequelize model (like they do with associate) to include e.g. epilogue middleware/override milestones, or change the endpoints, or specify which actions to use, etc.

I hope this helps a little bit, maybe together we could work on some documentation?

from epilogue.

shanemgrey avatar shanemgrey commented on June 17, 2024

No, unfortunately I moved onto another option. Sails in this case. I was having a hard time with sequelize more than anything and found that waterline did what I needed.

Thanks for checking in though. I would have contributed if I had stuck with it.

from epilogue.

codebased avatar codebased commented on June 17, 2024

great it has started working and your above approach with resource works well too. I will write an essay and post you for your approval.

from epilogue.

edthedev avatar edthedev commented on June 17, 2024

The basic example on the main page does not result in a working API.

Many lines necessary are missing, but even adding the implied lines doesn't result in an API being served.

In the very first example in README.md:

var rest = require('epilogue');
rest.initialize({
    app: app,
    sequelize: sequelize
});

The example is already incomplete, as app was never defined. Presumably, this line from the Express tutorial should have been included:

var app = express();

from epilogue.

payne8 avatar payne8 commented on June 17, 2024

Something else that would be helpful to see as an example, is how to reference or manipulate the data before it is sent as a response. For example I have a Users table and a users endpoint. But I don't want to return the password of the user. I can tell from the readme that I should use users.list.data(f) but I am not sure how to reference the data in order to manipulate it.

Thanks for the awesome library by the way it is really cool and really powerful.

from epilogue.

mbroadst avatar mbroadst commented on June 17, 2024

sorry guys this took far longer than it should have, committed in: b5d78e0

@payne8 you'll definitely want to use milestones for this, depending on what controller you're looking to modify you'd do something like:

users.list.send.before(function(req, res, context) {
    context.instances.forEach(function(instance) {
        delete instance.password;
    });

    context.continue();
});

from epilogue.

payne8 avatar payne8 commented on June 17, 2024

Thank you @mbroadst. I was able to figure out a way to do it by reading the tests. I will probably migrate to the .send.before milestone rather than the one I am currently using though.

from epilogue.

Related Issues (20)

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.