Skip to content

flandrade/express-typescript-scaffolding

Repository files navigation

An opinionated scaffolding: Express + TypeScript + Sequelize

CircleCI

An opinionated scaffolding to build an application with Express, TypeScript and Sequelize.

  • TypeScript is a superset of JavaScript that compiles to plain JavaScript.
  • TypeScript development's support with TSLint and ts-node.
  • The Sequelize library provides easy access to databases by mapping database entries to objects and vice versa.
  • Mocha and Chai for unit testing. In addition, factory-girl is the factory library to generate fake data for tests.
  • Other libraries:
    • ramda: a functional programming library.
    • bluebird: a third party promise library.
    • dotenv-safe: load environment variables from .env and ensure they are all present.

Getting started

Clone the repository

git clone git@github.com:flandrade/express-typescript-scaffolding.git
cd express-typescript-scaffolding

Install NVM and select the Node version

Install nvm to manage several Node versions. After install, run the following commands in the project directory:

nvm install
nvm use

Install your database

This scaffolding uses Postgres. In Linux, you can download the installer from Postgres. On Mac, you can use Postres App.

Setup the application

In order to setup the application, some environment variables are needed. For this, copy the .env.example to .env and define the variable

$ cp .env.example .env

This scaffolding requires the database scaffolding_development URI for development:

DATABASE_URI=postgresql://<user>:<password>@localhost/scaffolding_development

For the testing environment, the database is scaffolding_test:

DATABASE_URI=postgresql://<user>:<password>@localhost/scaffolding_test

Run the setup script

Run the following script to install the dependencies, create the databases and run the migrations for both development and testing.

./bin/setup.sh

Run the application

Start the application by running:

npm start

When started, the application will be available at http://localhost:3000/users

Tests

To run tests:

$ npm test

License

MIT