Description

A boilerplate for your next Typescript based API. It’s goal is to simply kick-start your API development and provide you with some of the best practices when building amazing and scalable REST APIs. 🔥

Using:

Installation

Setup

Make sure you have Postgres database running, as well as your Treblle credentials. Here are the required environment variables for running this application. Add them to your .env file.

# Postgres details
DATABASE_HOST=
DATABASE_PORT=
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_NAME=

# Seed initial user details for login
INITIAL_USER_NAME=
INITIAL_USER_EMAIL=
INITIAL_USER_PASSWORD=

# String secret for generating JWTs
JWT_SECRET=

# Treblle account information: treblle.com
TREBLLE_API_KEY=
TREBLLE_PROJECT_ID=

Before running the app

Migrate with this shortcut to add required entities to your Postgres database. Check TypeORM docs here for more features.

yarn typeorm:run-migrations

Running the app

# Development
yarn start

# Watch mode
yarn start:dev

# Production mode
yarn start:prod

Other features

NestJS features

This is build upon a NestJS init project following practices from the official documentation, so check their awesome docs to learn more! All default NestJS features should work as expected, as well as the CLI.

TypeORM migrations

To generate a new migration after adding your entity, you can just run the following:

There are also shortcuts for other TypeORM CLI commands, like:

Directory src/database/migrations is used for migrations by default.
Don’t forget to add your migrations into DatabaseModule after creating them, or else they won’t be run!

License

Copyright 2022, Treblle Limited. MIT licensed.

Read More

By |2023-01-21T11:21:48+00:00January 21st, 2023|Education|0 Comments

Leave A Comment