/skeleton-rest-api

skeleton rest api app on NodeJS

Primary LanguageJavaScript

express-rest-api

skeleton app on NodeJS

1)Express
2)sequelize ORM
3)Postgres DB

Start project

Create new .env file based on .env.example and fill it

npm i //Install dependencies

npm run pre-migrate //Create database if not exist in Postgres

npx sequelize db:migrate //Run migrations

npx sequelize db:seed:all //Run seeds with test data

npm run dev //Run project

Routes

all routes start at /api

Create migration

npx sequelize migration:generate --name %Name%

Structure

src
 ┣ controllers
 ┃ ┗ *.controller.js
 ┣ database
 ┃ ┣ migrations
 ┃ ┃ ┗ *.js
 ┃ ┣ seeders
 ┃ ┃ ┗ *.js
 ┃ ┣ config.js
 ┃ ┣ createDB.js
 ┃ ┗ database.js
 ┣ models
 ┃ ┗ *.js
 ┣ routes
 ┃ ┣ index.js
 ┃ ┗ *.js
 ┣ app.js
 ┗ index.js