Skip to content

Louis3797/express-ts-boilerplate

Repository files navigation

Express-Typescript-Boilerplate

A simple Express.js boilerplate server with typescript

contributors last update forks stars open issues license


Table of Contents

About the Project

Tech Stack

  • Express.js
  • Typescript
  • Yarn

Features

  • Package managament with Yarn
  • Testing with Jest and Supertest
  • Cross-Origin Resource-Sharing enabled using cors
  • Secured HTTP Headers using helmet
  • Logging with winston
  • Environment variables using dotenv
  • Compression with gzip
  • Git hooks with husky and lint-staged
  • Linting and enforced code style using Eslint and Prettier
  • Containerization with Docker

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

NODE_ENV

PORT

CORS_ORIGIN

See .env.example for further details

Getting Started

Prerequisites

This project uses Yarn as package manager

 npm install --global yarn

Installation

  git clone https://github.com/Louis3797/express-ts-boilerplate.git

Go to the project directory

  cd express-ts-boilerplate
  yarn install

Linting

  # run ESLint
  yarn lint
  
  # fix ESLint errors
  yarn lint:fix

  # run prettier
  yarn code:check

  # fix prettier errors
  yarn code:format
  
  # fix prettier errors in specific file
  yarn code:format:specific-file <file-name>

Running Tests

To run tests, run the following command

  yarn test

Run Locally

Start the server in development mode

  yarn dev

Start the server in production mode

  yarn start

Run with Docker

Build the container

  cd express-ts-boilerplate
  docker build . -t express-ts-boilerplate     

Start the container

  docker run -p <port you want the container to run at>:4040 -d express-ts-boilerplate    

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Louis-Kaan Ay

Project Link: https://github.com/Louis3797/express-ts-boilerplate

Acknowledgements