Skip to content

dannylwe/nodejs-express-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Getting started

  • npm init -y
  • npm install --save express body-parser

Install babel to convert to ES6

  • npm install --save-dev @babel/core @babel/cli @babel/node @babel/plugin-transform-runtime @babel/preset-env @babel/register @babel/runtime babel-loader

install eslint

  • npm install --save-dev eslint eslint-config-airbnb-base eslint-plugin-import

Install nodemon

  • npm install -g nodemon

Install sequelize

  • npm install -g sequelize-cli
  • touch .sequelizerc
  • npm install --save path
  • npm install --save sequelize pg pg-hstore
  • sequelize init

Install postgres

  • docker pull postgres
  • docker run --name new-postgresdb -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Go to postgres container

  • docker exec -it new-postgresdb psql -U postgres
  • show users: \du
  • show databases: \l
  • create database: CREATE DATABASE books;
  • create user with no password: CREATE USER danny;

create sequelize migration and model

  • sequelize model:generate --name Book --attributes title:string,price:string,description:string

Test Coverage

  • npm install --save-dev mocha chai chai-http nyc
  • mocha for testing, chai for assertion and nyc for coverage

Ref here:

About

REST Book API with node postgres.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published