Skip to content

vibhor13/vpn

This branch is 5 commits behind justsudheer/vpn:master.

Folders and files

NameName
Last commit message
Last commit date
Apr 21, 2022
Apr 21, 2022
Apr 26, 2022
May 3, 2022
Apr 26, 2022
Apr 21, 2022
Apr 21, 2022
Apr 21, 2022
May 3, 2022
Apr 21, 2022
Apr 25, 2022
Apr 26, 2022
Apr 21, 2022
Apr 27, 2022
Apr 25, 2022
Apr 25, 2022
Apr 26, 2022
Apr 25, 2022

Repository files navigation

Express Postgres Starter

A starter project for Node.js with Express and Postgres

Setup

Pre-requisites:

  • Docker for Desktop

Run docker-compose up in the root of the project.

It will bring up Postgres and the Express application server in development mode.

It binds the application server to localhost:3000, this can be re-mapped this by changing the first 3000 in 3000:3000 of ./docker-compose.yaml).

Postgres is exposed on port 35432. The connection string is postgres://user:pass@localhost:35432/db (username, password and database name are defined in ./docker-compose.yaml).

You can connect to Postgres using the psql client:

psql -h 127.0.0.1 -U user -W -d db

The default Docker CMD is npm start, ./docker-compose.yaml overrides this to npm run dev which runs the application using nodemon (auto-restart on file change).

Express API setup

The Express API is located in ./src/api.

Applications routes for resources are defined in ./src/api/index.js.

Global concerns like security, cookie parsing, body parsing and request logging are handled in ./server.js.

This application loosely follows the Presentation Domain Data Layering:

  • Presentation is dealt with in the ./src/api folder
  • Domain is dealt with in the ./src/modules folder. It's currently non-existent since we've only got generic user and session resources.
  • Data is dealt with in the ./src/persistence folder

Database setup + management

npm run migrate up will run the migrations.

npm run migrate down will roll back the migrations.

npm run migrate:create <migration-name> will create a new migration file in ./src/migrations.

To run the migrations inside of docker-compose. Which will run a bash instance inside the app container.

docker-compose run app bash

Followed by:

npm run migrate up

Session/Authentication management

Session management is done through a custom sessions table, /api/session endpoints (see ./src/api/session.js) and leveraging client-sessions.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 80.3%
  • Dockerfile 13.9%
  • Shell 5.8%