Loopback-PostgreSQL generator
Description
Loopback-PostgreSQL generator is a [yeoman] (https://github.com/yeoman/generator) package that allows you to scaffold a new REST API loopback project that are using:
- LoopBack - Node.js REST API framework
- PostgreSQL - PostgreSQL loopback connector
- Winston - Logging module that configured to write in DB, logfile and console
- .env module - Library for .env credentials management
- DB migrations - Database migration framework for Node.js, settings and commands are described below
Also current boilerplate uses S3 component and SMTP.
Install
- Install:
npm install -g generator-loopback-postgresql
- Install yeoman:
npm install -g yo
if it isn't exist yet - Run:
yo loopback-postgresql
Usage
After project generation you should edit your .env file and setup all correct credentials for your services.
.env
BUCKET=default.bucket.name
BUCKET_KEY=bucket.key
BUCKET_KEY_ID=bucket.id
RDS_HOSTNAME=localhost
RDS_PORT=5432
RDS_DBNAME=dbname
RDS_USERNAME=postgres
RDS_PASSWORD=postgres
SMTP_HOST=smtp.host.name
SMTP_USERNAME=smtp.user.name
SMTP_PASSWORD=smtp.password
DEBUG=*
Loopback Debug values
Migrations
You have an ability to work with migrations.
Before start you must edit settings for this module. ./migrations/database.json
A new application has a few scripts for db migrations:
npm run migrate up
The up command executes the migrations of your currently configured migrations directory.
npm run migrate down
The down command executes the migrations of your currently configured migrations directory.
npm run migrate reset
The reset command is a shortcut to execute all down migrations and literally reset all migrations which where currently done.
npm run migrate create
The create command creates templates for you, there are several options for this.
Directory of migrations by default is located at: ./migrations/
Further information about db migrations you can find on this page.