Skip to content

Exploring session based auth in express with redis, postgre and docker-compose!

Notifications You must be signed in to change notification settings

Ablasko32/Session_Auth_Express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Express.js Auth Example

About

A simple authetification example in express.js using express-session. The project is dockerized in a single docker-compose file for quick and easy development.

One command starts :

  • API server
  • PostgreSQL DB
  • Redis (for storing sessions)

Usage

Make sure you have Docker installed!

Configure .env as well as docker-compose.yaml file

Make sure to configure .env file ,use .env.example for guide.

Run:

docker compose up

Routes

  • /create-user

    Creates new user in DB, requires username and password, password in hashed with bcrypt

  • /login

    if valid stores userId in session

  • /logout

    destroys user session

  • /check-user

    returns userId or null if session not valid

Additional Features:

  • global error handling via ApiError class and custom error middleware

About

Exploring session based auth in express with redis, postgre and docker-compose!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published