ndelvalle / generator-api Goto Github PK
View Code? Open in Web Editor NEW🚀 Yeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express
Home Page: https://ndelvalle.github.io/generator-api/
License: MIT License
🚀 Yeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express
Home Page: https://ndelvalle.github.io/generator-api/
License: MIT License
Tests are passing, but CI is now working.
Related: https://circleci.com/gh/ndelvalle/generator-api
Is there an alternative package where it generates API with mysql?
? Server name: apiYotest
? Server description: trying yo to see nodejs api with mongo
? Server version: 0.1.0
? Author name: Myk
? Author email:
? Business models: (singular and comma separated) user, pet
? what should the database be named? api-yotest
result:
events.js:141
throw er; // Unhandled 'error' event
^
AssertionError: Trying to copy from a source that does not exist: /usr/local/lib/node_modules/generator-api/generators/app/templates/.gitignore
at EditionInterface.exports._copySingle (/usr/local/lib/node_modules/generator-api/node_modules/mem-fs-editor/lib/actions/copy.js:45:3)
at EditionInterface.exports.copy (/usr/local/lib/node_modules/generator-api/node_modules/mem-fs-editor/lib/actions/copy.js:23:17)
at gitignore (/usr/local/lib/node_modules/generator-api/generators/app/index.js:131:15)
at Object.<anonymous> (/usr/local/lib/node_modules/generator-api/node_modules/yeoman-generator/lib/base.js:431:23)
at /usr/local/lib/node_modules/generator-api/node_modules/run-async/index.js:26:25
at /usr/local/lib/node_modules/generator-api/node_modules/run-async/index.js:25:19
at /usr/local/lib/node_modules/generator-api/node_modules/yeoman-generator/lib/base.js:432:9
at processImmediate [as _immediateCallback] (timers.js:383:17)
Hi, how do I prevent duplicate users created in the database? for example having an email as their primary source of identity.
I have created multiple users with the same email but the only thing that changes is their _id, I don't want email to be the same. I've tried multiple things including using some of the build in functions but I cant get it to work.
Any help please?
Hi,
Thanks for creating this amazing project. I'm new to es6 and need some help router file.
I use chain auth middleware in routes like this before.
router.get('/', auth.hasRole('admin'), controller.find)
Using above code results in following error.
Cannot read property 'facade' of undefined
Could please explain how can i chain middleware with new syntax.
router.route('/test').get((...args) => controller.test(...args));
Also if you can explain facade pattern in readme file with example it will really helpfull
This is just cosmetic. I found it a bit confusing when I first read the generated code. Would it be better if we can rename that to be 'Model'? Thanks.
This is how model files are named now:
└───model/
├───user/
└───user-controller.js
└───user-facade.js
└───user-router.js
└───user-schema.js
I was just wondering since the directory already is named after the model, I think it would make sense to remove the model name from the files:
└───model/
├───user/
└───controller.js
└───facade.js
└───router.js
└───schema.js
What do you think @ndelvalle ?
Thanks for boilerplate. It's very helpful.
It's my first real project with express and mongoose, and I'm sorry if my question is stupid.
I'm working on dictionary, and have an Article model:
const articleSchema = new Schema({
wordTable: { type: String, required: true },
wordForms: { type: [String] }
})
I need new route /search/:text
This route not related to /article route, but method still related to article model:
Article.find({ wordForms: text })
I'm a little confused, where to place this code.
Can you give me an advice please?
Just curious why you did not use the syntax above?
Again, great API framework, very simple..
Just uploaded a version to heroku and it just works!
Is there a way to just create the nodejs api without the mongo?
The search results wont be correct as current route defaults for /resource/:id use findOne (with the req.query which is blank for this route)
Instead routes should use findById with the req.params.id to deliver the correct response
// routes.js
router.route('/events/:id')
.get((...args) => controllers.event.findById(...args));
How do we hook swagger, JWT packages on to the platform and what could be the best model for adopting api versioning within the platform?
This is an awesome project.
How would you handle security and could you make a version where there could be a choice to scaffold security?
Thanks
Just completed install and giving a try. After completing generation process, I execute npm run dev
as documented. I can debug this further this evening, but figured I would let you know of immediate issues
% npm run dev !4941
> [email protected] dev /Users/mikeerickson/Documents/Projects/test
> nodemon index.js
[nodemon] 1.9.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
/Users/mikeerickson/Documents/Projects/test/node_modules/milieu/lib/milieu.js:5
let ini; // Lazy loaded
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/mikeerickson/Documents/Projects/test/node_modules/milieu/index.js:2:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
[nodemon] app crashed - waiting for file changes before starting...
This is more an enhancement and a question, but it would be nice to have at least optional, support or integration with API docs: http://apidocjs.com, since this is a restful API design, make sense to have some kind of API documentation
I really like the concept behind this starter and I will be happy to contribute at some point. I think one of the few things missing is the possibility to the user to add testing or not.
As stated in #38 an example of the facade use cases would be helpful.
On node v4.4.7 with a generated app using defaults I get:
[nodemon] 1.10.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
/Users/Jeffrey/Projects/test-api/node_modules/milieu/lib/milieu.js:4
let ini; // Lazy loaded
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/Jeffrey/Projects/test-api/node_modules/milieu/index.js:2:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
Updating the eslintignore file doesn't seem to help. Can you help ?
This is a proposition of switching from https://github.com/expressjs/express to https://github.com/restify/node-restify. Some of the reasons are:
restify
framework.restify
is more robust when it comes to error handling (http://restify.com/#error-handling), since it comes with built-in Error
objects that are easily mapped to proper http errors.Hi, can you please provide me with an example of how to implement a function or route for example getUser, I am struggling to figure out how to implement a function in the controller for example.
EDIT* What I'm basically asking is if you can provide me an example of how I would add a custom function that just returns some text.
great job !
what about the option of getting the files structured by modules (users, customers, etc )
and not by type of file ( models, controllers, etc)
thanks
Chris
Hi,
I can see handleError and validationError functions inside lib/controller but they are not used any where. Could you please explain how to use them generated controllers.? Do you have any suggestion about how to do effiecent global error handling.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.