This Project Built form Sample project that using NodeJs [es6] with Postgres SQL
Control the APIs
src
├───controllers
├───db
│   └───configs
├───helpers
├───middlewares
├───models
└───routesCommand-line built-in
├───commands
│   ├───cli
│   ├───controllers
│   ├───models
│   ├───routes
│   ├───sql
│   └───stub
├───migrations
│   └───sql
└───srcgit clone https://github.com/pphatdev/sample-node-api-migration.gitcd ./apis-with-nodejs-es6make sure your database local is working. copy .env.exmaple to .env than change the env configuration.
If you skip this step you can't start the node service.
# App Enviroment
VERSION="v1"
APP_NAME="REST APIs with NodeJs"
NODE_ENV="development"
# DB Connection
DB_HOST="your host"
DB_NAME="your database name"
DB_PORT="your PORT"
DB_USER="your username"
DB_PWD="your password"cp .env.example .envnpm installYou can create multi table
npm run db:create table_namenpm run db:create table_name1 table_name2After Creating sql file you have to update the sql to your own table.
cd ./migrations/sqlnpm run db:migrateFinally you can start the project.
npm startand these what you see on terminal! 😎
♻️  Starting with: [development] Mode!
🌞  Web development:
🚀 Localhost: http://localhost:3000
🚀 Local Service: http://127.0.0.1:3000
🚀 Host Service: http://{ipv4}:3000
🌞  API development:
🚀 Localhost: http://localhost:3000/api/v1/
🚀 Local Service: http://127.0.0.1:3000/api/v1/
🚀 Host Service: http://{ipv4}:3000/api/v1/In this project you can create routes, controllers, and models by cli. How to do that please check documentation below.
npm run create:route routename1, routename2npm run create:controller controllername1, controllername2npm run create:controller controllername1, controllername2npm run create:model modelname1, modelname2You can create route, controller, and model by signle command.
npm run create:rcm rcmname