TypeScript Node.js Template Project
TypeScript Node.js Project.
π Using
- pnpm - Fast, disk space efficient package manager.
- TypeScript - a strongly typed programming language.
- Jest - a delightful Testing Framework with a focus on simplicity.
curl -fsSL https://get.pnpm.io/install.sh | sh -
pnpm -v
ποΈ Environment
If you are using fnm - Node.js version manager:
fnm use
Set your environment variable in .env
file.
π§πΏβπ» Build Setup
# install dependencies
pnpm i
# create `.env`
cp .env.development .env
# π§πΏβπ» Development: serve with hot reload
pnpm dev
pnpm lint
pnpm test
# Compile and transpile the TypeScript code:
pnpm build
# Compile and transpile the TypeScript code, and then runs the resulting `.js` application:
# Starts the app in production
pnpm start
If you want to run Unit tests every time you commit code, you can add pnpm test
to .husky/pre-commit
.
Deployment
In develop environment, build first:
pnpm build
In production environment, install dependencies and run builded source:
pnpm i --production --quiet
pnpm prod
ποΈ Special Directories
media
The media
directory is used to store supporting files for the application.
Things like requirement documentation, text outlines, etc.
This is the junk drawer for the project.
src
data
The data
directory holds the types (models/entities) and services (repositories) for data consumed by the application.
mock
The mock
directory contains your JSON mock data for testing purposes.
Editor - vscode
Extensions
- eslint
- β¨ prettier
- π docker
- π Better DockerFile Syntax
- Code Spell Checker
- markdown lint
- sonar lint
Options: