An opiniated NodeJS TypeScript Starter Project with coding conventions and ESLint rules using VS Code editor.
npm ci
npm build
npm start
TypeScript source code are in ./src
directory. Build output are in ./build
.
EditorConfig is supported by most IDEs / Editors to help maintain consistent coding styles. The configuration is defined in .editorconfig
.
VS Code extension: EditorConfig
ESLint is a static code analysis tool with both style and non-style related rules. TypeScript is supported via the packages here.
Airbnb style guide is adopted using airbnb-typescript
config.
The excellent config is used to manage application configuration specified in ./config
directory. See here for the configuration file loading order / precedence.
Supports debugging in TypeScript and in watch mode. See ./.vscode/launch.json
for more details.
docker.env
file is provided for convenience to provide the required environment variables or to override image defaults to start the container.
# Builds docker image
npm run build:docker
docker build -t my-app .
# Runs docker image
npm run start:docker
docker run --rm -it -p 3030:3030 --env-file ./docker.env my-app
Development dependencies is excluded from the Docker image using multi-stage docker builds.
Module aliasing can simplify module imports using absolute paths using TypeScript Path Mapping. However, the module resolution will fail during runtime as NodeJS module resolution does not support it. The npm package module alias
is used to fix this. The package.json
needs to be configured similarly to tsconfig.json
. See usage for more details.
// tsconfig.json
"outDir": "./build",
"baseUrl": "./src",
"paths": {
"@/*": ["*"],
"@services/*": ["services/*"]
}
// package.json
"_moduleAliases": {
"@": "build",
"@services": "build/services"
}
-
Testing
-
Coverage