A quick start template for bootstrapping a new NODE Express API application using sequelize as the ORM.
git clone https://github.com/andela-git/senplate.git
cd senplate
cp .env.example .env
- Listens on PORT 9000 by default.npm install
npm test
- To run testsnpm start
- Your app should be running on https://localhost:9000/
index.js
- Application entry point- app [dir] - application folder
- config -
config.js
::sequelize configuration file - controllers - application controllers folder, app logic goes here
- helpers - helper scripts to ease repetitive tasks goes here.
- migrations - database migration files
- models - application database models definition goes here
- routes - application requests, requests format and definition goes
- api [dir] - api folder to carefully house all your api routes file
hello.js
- hello default route (optional)
- api [dir] - api folder to carefully house all your api routes file
- seeders - database seeders folder
- config -
- test [dir]
- feature [dir]
- unit [dir]
test.js
Out of the box structure for building Node Express APIs, comes preconfigured with the following; ###Dependencies
- body-parser - Node.js body parsing middleware. Parse incoming request bodies in a middleware before your handlers, available under the req.body property. body-parser
- express - Fast, unopinionated, minimalist web framework for node. express-framework
- morgan - HTTP request logger middleware for node.js. morgan
- sequelize - Sequelize is a promise-based Node.js ORM for Postgres, MySQL, SQLite and Microsoft SQL Server. It features solid transaction support, relations, read replication and more. sequelize
- Mocha - Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. mochajs
- Chai - Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. chai
- chai-http - HTTP integration testing with Chai assertions.chai-http
-
MIT
The project needs to be built into a CLI to npm tool such that with just one command, an install can be made. something like;
npm install -g senplate
sen create <app name>
cd <app name>
sen do controller User
sen do model:migration User