git clone git@github.com:SideHustlers/KitchenApp-api-template.git
cd KitchenApp-api-template
npm install
mkdir keys && cd keys
ssh-keygen -t rsa -b 4096 -m PEM -f [NAME].key
# Don't add passphrase
open rsa -n [NAME].key -pubout -outform PEM -out [NAME].key.pub
npm run local_migrations
# npm run dev_migrations
# npm run prod_migrations
npm run local
# npm run dev
# npm run prod
- NPM
- Dedicated Local PostgreSQL database
- index.js
- Configurations (config)
- Dependencies (node_modules)
- Middlewares (middlewares)
- Migrations (migrations)
- Models (models)
- Helpers (helpers)
- Routes (routes)
- Dockerfiles, Gitlab-CI files
index.js
is the entrypoint for the express application. It houses the application code to start a server on a specified port and to connect routes.
$const port = 8000
- Local Development Configuration =>
local
- Local Testing Configuration =>
local_test
- Gitlab CI Testing Configuration =>
test
- Development Branch Configuration (Blue) =>
development
- Production / Master Branch Configuration (Green) =>
production
$ npm install
- Auth middleware is used to authorize a user by validating any authorization token
- Permission middleware is used to check ownership of a resource.
This application uses Sequelize to manage models and database migrations.
$ node_modules/.bin/sequelize model:create --name [name_of_your_model] --attributes [list_of_attributes]
$ node_modules/.bin/sequelize migration:generate --name [name_of_your_migration]
$ node_modules/.bin/sequelize db:migrate
All models can be found in the models/
directory and migrations can be found in the migrations/
directory
Response Helpers are pre-built responses meant to reduce code redundancies and improve error handling.
This application has sample response helpers that output success(200), bad (400), and error(500) responses.
Seeders provied by Sequelize are used to manage all data migrations, and to populate testing databases with initial placeholder values.
$ node_modules/.bin/sequelize seed:generate --name [seed_name]
$ node_modules/.bin/sequelize db:seed:all
$ node_modules/.bin/sequelize db:seed:undo:all
- Write your tests in
{your_test_name}.js
file - Add your tests in main.js
require('./{your_test_name}.js')
$ npm test
Docker images are automatically generated and stored during development or production phases of Gitlab CI pipelines.
- prod.Dockerfile defines a production environment image
- dev.Dockerfile defines a development environment image