A super simple Node JS API demo built with Express, for PostgreSQL using Sequelize ORM. Has a folder structure that follows sequelize-cli conventions with a pod structure for routes and controllers.
Stack
Testing
- Authentication with JSON Web Token
- Email, Password validations
- User login and registration
- Full API and Unit test coverage
- Simple demo endpoint template
- Logging with winston
- api - contains all endpoint folders and router file
- pod folder - contains route and controller for pod
- router.js - contains all router endpoints for the api
- config - all config settings and middlewares
- migrations - sequelize
- models - sequelize
- seeders - sequelize
- services - folder for all utils and services
- tests - folder for all test files
Make sure to install and run PostgreSQL first. There are a list of package.json scripts that include core sequelize migrations and seeds.
brew update
brew install postgres
Then you'll need to adjust the config file config/db.js
to suit your setup.
Then run npm run reset
and your db will create from scratch and seed data under
the db name vanilla_dev
.
Running npm run dev
will start your dev server where needed.
You'll need to setup the test server using npm run resettest
. To trigger the mocha/chai tests enter:
npm run test
There is a postman collection file for API testing and development in
./node-starter.postman_collection.json
. It contains scripts and
basic CRUD for:
-
/auth
- [POST] Register (/register)
- [POST] Login (/login)
-
/demos
- [POST] Single demo (/ - with auth)
- [PATCH] Single demo (/:id - with auth)
- [DEL] Single demo (/:id - with auth)
- [GET] All demos (/)
- [GET] Single demo (/:id)
Node Starter uses Sequelise ORM to interact with Postgres. Install globally
on your dev machine using npm run global sequelize-cli
then run commands with
sequelize
or alternately run commands locally in your dev folder with the
built in dev package ./node_modules/.bin/sequelize init
.