/express-typescript-seed

Node API seed written in typescript using Express, Sequelize, Passport, and RabbitMQ

Primary LanguageTypeScript

Express Typescript Seed

Node.js with Express 4 written in Typescript

PostgreSQL database under Sequelize ORM

OAuth2 with Passport

Roles based access with Connect Roles

Message brokering with RabbitMQ for running background tasks like sending e-mails and uploading images to S3

Environment based configuration using Dotenv

Integration Testing with SuperTest

Quickstart

npm install -g yarn
yarn install
# install docker https://docs.docker.com/install/
docker stack deploy -c local-infra.yml infra
# connect to postgres via postgres:password@localhost:5432
# create 'seed' user with password 'password'
# create 'seed' database and set the 'seed' user as the owner
cp .env.example .env
yarn run start
# wait for app to start
yarn global add sequelize-cli
sequelize db:seed:all 

Environment Setup

This project uses the Dotenv library to load sensitive data such as database passwords and client secrets.

There is a .env.example file included at the root of this project as an example, rename it to '.env' (.env is not under version control). Update the .env file with the pertinent information for your project.

RabbitMQ

Install and run RabbitMQ with the default settings (or use the provided local-infra.yml in conjunction with docker-compose/swarm)

Database

You will need a PostgreSQL database running on localhost:5432 (or use the provided local-infra.yml in conjunction with docker-compose/swarm)

The setup of PostgreSQL is beyond the scope of this guide. Please reference the Install Guides for help installing PostgreSQL on your machine.

Once PostgreSQL is installed and running, create a new database called seed. Create a new user named seed. Make this user the owner of the newly created database.

Since the tables defined in the entities do not already exist, Sequelize will attempt to build them once you start the server.

Running the app

yarn install
yarn run start

You can also run the app in debug mode and attach a Debugger in Webstorm

yarn run debug

Once the app is running and the tables are created, you can seed the database with the sequelize-cli. Install the sequelize-cli by running

 yarn global add sequelize-cli

then run

sequelize db:seed:all 

Running the tests

yarn run test

Contact

Kevin Kolz - kckolz@gmail.com

License

MIT