A web server boilerplate built on TypeScript and MongoDB.
There are four main npm
scripts that you should familiarise yourself with:
npm run build
:
- Runs the TypeScript transpiler to generate
.js
files and outputs them todist
.
npm start
:
- Runs
dist/server.js
withnode
. You will need to make sure you have previously runnpm run build
to compilesrc/server.ts
. This script should be used when running the server in production.
npm run dev
:
- Runs
src/server.ts
withnodemon
andts-node
, resulting in a development workflow that avoidstsc
transpilation steps and restartsts-node
as changes are made to.ts
files insrc
. If you would prefer to runtsc
compiled.js
files in watch mode, you can redefinenpm run dev
to point tonpm run dev:js
.
npm run test
:
- Runs all tests with
jest
and outputs a coverage report. Tests can be placed in either a__tests__
directory inside any level of thesrc
folder, or in a separatetests
directory at the root of the project folder. Tests should be named*.test.ts
or*.test.js
.