Skip to content

ezhabimana/node-typescript-postgres-cookie-cutter

Repository files navigation

Skeleton of a node.js / typescript / express / postgres app

Install Node / NPM

https://docs.npmjs.com/getting-started/installing-node

Install TypeScript

https://www.npmjs.com/package/typescript

Setup a Postgres Database

The database credentials will be used in the sebsequent steps to configure the .env file. You can create a local DB or use a remote DB for example AWS RDS

Create table in your Postgres DB:

CREATE TABLE test (
  testcolumn VARCHAR(20)
);

Download this repo

download and run npm install

Set the following ENV VARs for your DB Connections:

export DB_USER='' DB='' DB_PASS='' DB_HOST='' DB_PORT='' DB_MAX_CLIENTS='' DB_IDLE_TIMEOUT_MS=''

this can also be done by creating a .env file in the root of this project see .env.example for a reference

Open '.env file and fill in the database credentials retrievd from "Setup Postgres Database" step

Quickstart: transpile, lint and start the app all at once

npm start

Or each step individually:

  1. Transpile TypeScript to the build folder

run tsc

  1. Run ESLint

npm run lint

  1. Run your built node app

node build/app.js

Routes

http://localhost:3000/healthcheck and root return healthcheck

http://localhost:3000/servertime - returns servertime

http://localhost:3000/transaction - deletes then inserts into your DB using a transaction

Testing

  • basic unit test examples have been added using Jest

npm test

node-postgres package

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published