- Node.js 8.4.x
- NPM 5.4.x
- Postgres 9.6.4
First, ensure your system meets the application requirements above, and you have
created a database and updated the configuration for it in pm2-dev.json
.
sudo apt-get install postgresql-9.6
nvm install
Next, install the application dependencies:
npm install
Then migrate your database:
npm run db:migrate
And finally, start a development server:
npm run dev
We use PM2 for process management in development.
The environment configuration is in pm2-dev.json
.
The application is built with the Koa web framework.
We use Sequelize for an ORM and Postgres for the database.
We also use sequelize-cli
for migrations. The configuration is located in db/config.json
.
To migrate your database:
npm run db:migrate
To create a new migration:
npm run migration:generate -- --name <name>
Rolling back migrations is only supported in development:
NODE_ENV=development npm run db:migrate:undo:all
You can also use the sequelize cli to generate models for you:
npm run model:create -- --name <name> --attributes name:string,state:boolean,birth:date,age:integer
We use koa-trie-router for routing.
We use Nunjucks for templating.
We use Nodemailer with SMTP transport to send emails. Using nodemailer-wellknown, we can easily support many third-party email services.
Emails are sent to console output if SMTP_TRANSPORT=stream
by deafult.
This is useful for development purposes.
If you want to send emails, change the SMTP_TRANSPORT
configuration in
pm2-dev.json
to a supported service,
and make sure to provide valid SMTP_USER
and SMTP_PASSWORD
configuration for that service.
To change the email address of the sender, update the SMTP_ENVELOPE_FROM
configuration in pm2-dev.json
.
Templates are rendered with node-email-templates using Nunjucks for templating and node-sass for styling.
We use Mailgun's transaction email templates as a boilerplate for email templates.