Skip to content
/ ts-api-template Public template

An opinionated template for building a NodeJS/TypeScript API

License

Notifications You must be signed in to change notification settings

cmdshepard/ts-api-template

Repository files navigation

TypeScript API Template

An opinionated template for building a NodeJS/TypeScript API.

Stack

  • NodeJS/TypeScript
  • Express
  • Express Validator
  • Prisma ORM (configured for PostgreSQL)
  • Redis
  • BullMQ
  • Firebase Auth
  • Morgan for HTTP logging
  • Winston for other logging

System Requirements

  • Docker
  • NodeJS
  • NVM
  • Yarn

Setup Development

Install Node & Node modules, then set environment variables.

# Install Node 18
$ nvm install 18

# Use Node 18 in current shell session
$ nvm use

# Install Node modules
$ yarn

# Create a PostgreSQL database in a Docker container
$ yarn db:create

# Create a Redis database in a Docker container
$ yarn redis:create

# Copy environment variables
$ cp .env.example .env

You'll need a Firebase key to a development project to begin.

Save this file as firebase-key.json in the project directory and set the full path of the file as the value for GOOGLE_APPLICATION_CREDENTIALS in your .env file.

# Migrate the database schema 
$ yarn db:migrate

Start Development

# Use correct node version
$ nvm use

# Start the server
$ yarn start