This Project Built form Sample project that using NodeJs [es6] with Postgres SQL
Control the APIs
src
├───controllers
├───db
│ └───configs
├───helpers
├───middlewares
├───models
└───apis
Command-line built-in
├───commands
│ ├───cli
│ ├───controllers
│ ├───models
│ ├───routes
│ ├───sql
│ └───stub
├───migrations
│ └───sql
└───src
git clone https://github.com/pphatdev/sample-node-api-migration.git
cd ./apis-with-nodejs-es6
make 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 .env
npm install
You can create multi table
npm run db:create table_name
npm run db:create table_name1 table_name2
After Creating sql file you have to update the sql to your own table.
cd ./migrations/sql
npm run db:migrate
Finally you can start the project.
npm start
and 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, routename2
npm run create:controller controllername1, controllername2
npm run create:controller controllername1, controllername2
npm run create:model modelname1, modelname2
You can create route, controller, and model by signle command.
npm run create:rcm rcmname