Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

garatortiz/express-starter-kit

Repository files navigation

Build Status Greenkeeper badge contributions welcome code style: prettier Maintainability Test Coverage

Express starter kit

Starter project for creating an Express server, using:

  • ExpressJS
  • Sequelize (PostgreSQL)
  • Babel
  • Prettier
  • ESLint

Installation

Clone the repository and run npm install

git clone https://github.com/matiasgaratortiz/express-starter-kit.git
cd express-starter-kit
npm install

Starting

Use npm run dev for development mode, and npm start for production modes. The server will run on port 3000.

Database

This starter kit uses PostgreSQL was its main data store. You can install it locally, use docker or configure a remote DB.

Create an user and a database for the project

~$ sudo -u postgres -i

postgres@hostname:~$ createuser johndoe
postgres@hostname:~$ createdb mydatabase
postgres@hostname:~$ psql

postgres=# alter user johndoe with encrypted password 'mypassword';
postgres=# grant all privileges on database mydatabase to johndoe;
postgres=# \q

You now should be able to do:

~$ psql postgres://johndoe:mypassword@localhost/mydatabase

Note that even if you use Docker and have not installed Postgres localy, you still need to install the psql client.

Migration and Seed

To perform the migration of the database, just run the following command.

npm run migrate

If you want to undo the last migration, you can use npm run migrate:undo, or npm run migrate:undo:all to undo all migrations.

If you need to load test data, you can use seeds in the following way

npm run seed

or use npm run seed:undo to undo all data loads made.

ENV

You can find an example ENV file at .env.example.