https://github.com/ezy/sneap-express-pg-sequelize
A super simple Node JS API demo built with Express, for PostgreSQL using Sequelize ORM.
https://github.com/ezy/sneap-express-pg-sequelize
api api-server express express-js expressjs node nodejs postgres postgresql sequelize server
Last synced: 3 months ago
JSON representation
A super simple Node JS API demo built with Express, for PostgreSQL using Sequelize ORM.
- Host: GitHub
- URL: https://github.com/ezy/sneap-express-pg-sequelize
- Owner: ezy
- License: mit
- Created: 2018-11-19T22:01:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T21:57:10.000Z (over 3 years ago)
- Last Synced: 2025-01-24T14:43:51.613Z (over 1 year ago)
- Topics: api, api-server, express, express-js, expressjs, node, nodejs, postgres, postgresql, sequelize, server
- Language: JavaScript
- Homepage:
- Size: 1.19 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SNEAP - ExpressJS NodeJS API server with Postgres & Sequelize
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.
[](https://opensource.org/licenses/MIT)
**Stack**
* [Node.js](https://nodejs.org/en/)
* [PostgreSQL](https://www.postgresql.org/)
* [Sequelize](http://docs.sequelizejs.com/en/v3/)
* [Sequelize-CLI](https://github.com/sequelize/cli)
* [JSON Web Token](https://jwt.io/)
**Testing**
* [Mocha](https://mochajs.org/)
* [Chai](http://chaijs.com/)
* [Supertest](https://github.com/visionmedia/supertest)
### Features
- [x] Authentication with JSON Web Token
- [x] Email, Password validations
- [x] User login and registration
- [x] Full API and Unit test coverage
- [x] Simple demo endpoint template
- [x] Logging with winston
### Folder structure
* **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
### To run locally
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.
### Testing
You'll need to setup the test server using `npm run resettest`. To trigger the mocha/chai tests enter:
```
npm run test
```
#### Postman
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)
#### Sequelize ORM
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`.