Skip to main content
  1. Experiences/

express-sequelize-ts

·341 words·2 mins
Detail codes on Github

Overview #

I made this boilerplate to develop some legacy node.js services in my workplace.
trying to make a boilerplate that can be used in various situations. 🧑‍💻
I hope this boilerplate will help someone like me 🥸.

Description #

A TypeScript-based boilerplate for creating a web application using the Express framework and the Sequelize ORM.
Made with Express, TypeScript, ESLint, Prettier, Jest, and Docker.

Features #

Developer experience #

  • 🚚 Express for handling HTTP requests and responses
  • 💾 Sequelize ORM for interacting with a database
  • 🟦 TypeScript for strong typing and better code organization
  • 🛠 Jest for unit and integration testing
  • 🚧 ESLint for linting
  • 🎨 Prettier for code formatting
  • 🐬 Docker for containerization

Back-end app features #

  • 🚫 JWT authentication for secure access to the API
  • 🎢 Layered architecture. (Controller, Service, Repository, Model)
  • ♻️ Data Transport Object (DTO) for data validation
  • 📦 Dependency injection for better code organization
  • 📝 Swagger for API documentation

Requirements #

  • Node.js
  • Yarn
  • SQLite (or any other database supported by Sequelize)
  • Docker (optional)

Getting Started #

Run the following commands to set environment variables and install dependencies:

set environment variables #

## set environment variables
#### make .env.{NODE_ENV} file using .env.example file
#### EX) .env.development | .env.test
$ cp .env.example .env.development

install dependencies #

## install dependencies
#### using yarn
$ yarn install

#### using Docker
$ yarn docker:build

then, you can run locally in development and test mode:

## run locally in development and test mode
#### using yarn
$ yarn dev | test:integration | test:unit:all | test:unit {path}

#### using Docker
$ yarn docker:dev | docker:test

check the swagger documentation at http://localhost:3000/api-docs

and also you can call test API endpoints:

// http://localhost:3000/api
// Content-Type: application/json
{
  "message": "Hello World"
}

Deploy to production #

you can deploy to production using yarn or Docker:

## using yarn
$ yarn build
$ yarn start

## using Docker
$ yarn docker:prod

What’s next? #

  • Add unit test
  • Add integration test
  • Add docker-compose
  • Add swagger
  • Write more specific documentation
  • Develop a new feature