A basic, pre-configured Node.js app to be used as starting template using for example degit
. Includes the following pre-configured:
- Node 18
- Typescript 5 with path mapping from
@/*
tosrc
. So@/modules/foo
maps to./src/modules/foo
. The path mapping is fixed automatically when building, so the resulting Node.js JS project can resolve files. - Eslint configured for Typescript
- Prettier
- Jest testing using TS, via
ts-jest
. - Uses
esbuild
instead ofts-node
for developing. Blazing fast you know. - Dockerfile with multi-step build based on
slim
image (only 185Mb base image size after compilation). - Basic Github pipeline (
ci.yml
) that cachesnode_modules
, and then runs lint, test and compile TS onpush
andpull_request
tomain
branch only.
A note on slim
base image: see here Image Variants regarding this. In case something wrong happens during the build, switch to node-18
image for safety, specially if using dependencies with native binaries (like sharp
for image manipulation and so on).
Node version 16, all dependencies latests versions as of March 15th 2022.
Create a new Node service based on this repo with
npx degit cdelaorden/node-ts
This is fast and doesn't include git info. Is just a fresh copy of the latest version.
- Modify the README and
package.json
details, so they don't point to this repository anymore (url
,author
,name
,bugs
,homepage
and so on). - Add your preferred stack! Choose a DB, add a
docker-compose.yaml
for local development, add dependencies and code your app. This simply is the starting point, with some commands and configurations ready.
-
npm run dev
Starts dev environment locally with superfastesbuild
transpilation +nodemon
for hot reload. -
npm test
Single run of all tests with Jest -
npm run tdd
Runs test with Jest in watch mode -
npm run ts-compile
Compiles TS withtsc
(slower, but real type checking) -
npm run lint
Runs Eslint -
npm run coverage
Runs Jest and outputs coverage info
-
npm run build
Compiles TS tobuild
output (which is .gitignored) -
npm run start
For production running, executes JS-compiled app inbuild/index.js
(needs previousbuild
step) -
docker build .
Builds the Docker image. Remember to tweak theDockerfile
if custom dependencies are needed inside the container for your app.