Skip to content

Clean and simple starter project for Node.js, NestJS and TypeScript

Notifications You must be signed in to change notification settings

icewind/nest-typescript-starter

Repository files navigation

Nest Logo

Description

Simple and clean starter project for Nest framework.

Usage

Get the source code by using this command

git clone [email protected]:icewind/nest-typescript-starter.git <project_name> && cd <project_name>

Then detach it from the original repository. Since this project does not use submodules, it is safe to remove a .git folder and initialize a new repository. WARNING This snippet performs force push, so you have to make sure there is no any important information in the remote origin. Otherwise, you have to merge it carefully.

rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin <remote-repository-uri>
git push -u --force origin master

To provide your app an environment, you may copy .env.example to .env and add all required variables. If you use Docker for development you may do the same with docker-compose.example.yml. IMPORTANT In case you use docker you have to run all commands inside the container by using docker run/exec <container> <command>

Installation

I'm trying to keep all dependencies up to date the most of them are specified with latest version. To fix particular versions you need to run npm install command. It will make you a file package-lock.json with exact versions available at the moment. Add this file to your version control system.

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
npm run start:prod

For docker there is only one option available and it is

docker-compose up

You may add '-d' flag in case you want to detach a process from the current terminal.

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Additional commands

There are a list of additional commands to help you make some actions faster.

Create a new migration file

npm run migrations:create -- -n "MigrationName"

Once you created an entity, you can generate SQL query for the migration by using

npm run db:schema:log

Run migrations

npm run migrations:run

Revert migrations

npm run migrations:revert

Generate entities from database schema

npm run migrations:generate

TypeORM generates migrations as typescript files. And in a production environment there is no need to use TS. So you may use

npm run migrations:run:production
npm run migrations:revert:production

to use transpiled js files instead.

About

Clean and simple starter project for Node.js, NestJS and TypeScript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published