All Projects → ndelvalle → Generator Api

ndelvalle / Generator Api

Licence: mit
🚀 Yeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Projects that are alternatives of or similar to Generator Api

Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (-11.74%)
Mutual labels:  api, rest-api, mongoose, expressjs
Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (-40.89%)
Mutual labels:  api, rest-api, mongoose, expressjs
Node Typescript Mongodb
node js typescript mongodb express generator yo
Stars: ✭ 96 (-61.13%)
Mutual labels:  rest-api, mongoose, yeoman, yeoman-generator
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-80.16%)
Mutual labels:  api, rest-api, yeoman, yeoman-generator
Generator Expressjs Rest
Project template for an ExpressJS application
Stars: ✭ 41 (-83.4%)
Mutual labels:  api, rest-api, yeoman
generator-espress
an opinionated yeoman generator that scaffolds a mvc express webapp completely in es6
Stars: ✭ 20 (-91.9%)
Mutual labels:  mongoose, yeoman-generator, expressjs
Rest Api Nodejs Mongodb
A boilerplate for REST API Development with Node.js, Express, and MongoDB
Stars: ✭ 672 (+172.06%)
Mutual labels:  api, rest-api, expressjs
Generator Sails Rest Api
Yeoman generator for scaffolding Sails REST API with predefined features
Stars: ✭ 336 (+36.03%)
Mutual labels:  rest-api, yeoman, yeoman-generator
Rest Hapi
🚀 A RESTful API generator for Node.js
Stars: ✭ 1,102 (+346.15%)
Mutual labels:  api, rest-api, mongoose
Rest
REST API generator with Node.js, Express and Mongoose
Stars: ✭ 1,663 (+573.28%)
Mutual labels:  rest-api, mongoose, yeoman-generator
Fastify Api
A blazing fast REST APIs with Node.js, MongoDB, Fastify and Swagger.
Stars: ✭ 138 (-44.13%)
Mutual labels:  api, rest-api, mongoose
Drago
A flexible configuration manager for Wireguard networks
Stars: ✭ 204 (-17.41%)
Mutual labels:  api, rest-api
Generator Web Extension
Advanced WebExtension generator that creates everything you need to get started with cross-browser web-extension development.
Stars: ✭ 212 (-14.17%)
Mutual labels:  yeoman, yeoman-generator
Express Api Es6 Starter
Build APIs with Express.js in no time using ES6/ES7/ESNext goodness.
Stars: ✭ 212 (-14.17%)
Mutual labels:  api, expressjs
Express Es6 Rest Api
🔋 Starter project for an ES6 RESTful Express API.
Stars: ✭ 2,401 (+872.06%)
Mutual labels:  api, mongoose
Openapi Directory
🌐 Wikipedia for Web APIs. Directory of REST API definitions in OpenAPI 2.0/3.x format
Stars: ✭ 2,635 (+966.8%)
Mutual labels:  api, rest-api
Magic
Create your .Net Core/Angular/Database CRUD Web apps by simply clicking a button
Stars: ✭ 214 (-13.36%)
Mutual labels:  api, rest-api
Symfony Flex Backend
Symfony Flex REST API template project
Stars: ✭ 214 (-13.36%)
Mutual labels:  api, rest-api
Datoji
A tiny JSON storage service. Create, Read, Update, Delete and Search JSON data.
Stars: ✭ 222 (-10.12%)
Mutual labels:  api, rest-api
Swiftdailyapi
A Swift API framework for ZhiHu's Daily News.
Stars: ✭ 204 (-17.41%)
Mutual labels:  api, rest-api

generator-api

Codeship Status for ndelvalle/generator-api dependencies Status devDependencies Status Codacy Badge

NPM

Yeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express. The fastest way to get your project up and running using an awesome stack.

generator

Getting started

  • Make sure you have yeoman installed on your machine: npm install -g yo
  • Install the generator globally: npm install -g generator-api
  • Run: yo api, or yo and choose Api option

Running the generated project

Make sure you have node version >= 6 because this project uses native supported ES6 features.

Development

  • Run: mongod to start the local mongodb in a separated terminal instance (If you don't have mongodb installed locally, visit It's webpage to learn how to install it).
  • Run: npm run dev to run the app (By default the app will run at localhost:8080, you can change this in the config file).

Did you choose Docker (🐳) support?

You only need Docker and docker-compose installed, forget about having node, mongodb or npm.

  • Run: docker-compose up to run the app. You might need sudo for this one.

NOTE: The Dockerfile uses node:latest as its starting point, if you wish to use another version of Node check out the available ones here.

Production

You'll likely be consuming mongodb as a service, so make sure to set the env var pointing at it. Then run npm start.

Using Docker

Build the Docker container and run it:

sudo docker build -t <image-name> .
sudo docker run \
  -p <host-port>:8080 \
  -d <image-name> \
  -e MONGO_DB_URI=mongodb://<username>:<password>@<host>:<port> \
  npm run start

Architecture

Assuming we use user and pet models the generated project will look like this:

├───index.js
├───routes.js
├───package.json
├───config.js
└───lib/
|   ├───controller.js
|   ├───facade.js
└───model/
    ├───user/
    │   └───controller.js
    |   └───facade.js
    |   └───router.js
    |   └───schema.js
    └───pet/
        └───controller.js
        └───facade.js
        └───router.js
        └───schema.js

Controller:

HTTP layer, in this instance you can manage express request, response and next. In lib/controller are the basic RESTful methods find, findOne, findById, create, update and remove. Because this class is extending from there, you got that solved. You can overwrite extended methods or create custom ones here.

Facade:

This layer works as a simplified interface of mongoose and as business model layer, in this instance you can manage your business logic. Here are some use case examples:

  • Validate collection x before creating collection y
  • Create collection x before creating collection y

In lib/facade you have the basic support for RESTful methods. Because this class is extending from there, you got that solved. You can overwrite extended methods or create custom ones here. Also you can support more mongoose functionality like skip, sort etc.

Model subgenerator

Once you have the generated project, if you want to add a new model you can simply run yo api:model. This will generate a new folder under model, in order to make it work, you just need to import the route into the routes.js.

Example:

  • Run yo api:model, write foo (What ever model name you want)
  • Go to routes.js and import the new generated model route const foo = require('./model/foo/router')
  • Use the imported route router.use('/foo', foo)

Contributing

Contributors are welcome, please fork and send pull requests! If you find a bug or have any ideas on how to improve this project please submit an issue.

License

MIT License

Style guide

Standard - JavaScript Style Guide

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].