Designed as a ready-to-go template for developing a Node TypeScript server. It uses the following main dependencies:
expressfor the general web app frameworkzodfor schema validationpgfor the database (PostgreSQL)
When you fork this repo, replace all the instances of the name node-server-template
with your repo/service name, and replace the example files in the routes, service,
schemas, and model layers with your real-life code.
The currently-used port is 3000, which you can change in app.ts if desired.
- Install
nvm, then runnvm iandnvm useto install Node. - Install the
dockerCLI (the easiest way is likely to install Docker Desktop).
When you first setup the server locally, you will need to run the following:
npm ci
npm run startDb
npm run migrate up
You can then run the server with npm start. This will compile the server and run
it in watch mode, so it will automatically recompile and restart on any src changes.
npm run migratewill runnode-pg-migrate. See the docs here for details. Some common uses:npm run migrate create <myMigrationName>will create a new migration.npm run migrate upwill run all migrations.npm run migrate downwill undo all migrations (essentially fully resetting the DB).
npm run compilewill just compile without running the server.npm run lintCheckwill check for ESLint errors;npm run lintFixwill fix them.npm run formatCheckwill check for prettier errors;npm run formatFixwill fix them.npm run stopDbornpm run restartDbwill stop or restart the DB in Docker.