Comments (9)
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:
- https://github.com/dchester/epilogue/blob/master/tests/support.js
- https://github.com/dchester/epilogue/blob/master/tests/resource/resource.test.js#L22
from epilogue.
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.
@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.
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.
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.
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.
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.
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.
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)
- Support to check if Postgres array contains string?
- create inserts nulls on postgres db? HOT 1
- Workflow for pull requests? HOT 2
- Typescript support? HOT 4
- AResouce.list.data.after is not called if AResouce.list.data is not presented
- Controller List is not applying attributes of Model Scope as specified in req.query.scope HOT 1
- search by parameter 'q' does not work HOT 12
- Order of associations HOT 1
- repo unmaintained! active fork: https://github.com/tommybananas/finale HOT 4
- How to add another options item while creating an model instance?
- app[self.method] is not a function
- [Read Endpoint] Get data from two models HOT 1
- Filtering/sorting by association fields
- Project status HOT 1
- EpilogueError: internal error HOT 1
- Sorting ignored with hasMany relationships
- How to define all API routes to be in a separate group
- How do I add auth to all actions of a Resource? HOT 1
- How can I assign fetching items to POST request?
- Cannot set headers after they are sent to the client HOT 5
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 epilogue.