This repository is a working express.js server for quickly scaffolding the backend of my future projects. It provides a basic folder structure and takes care of (session based) user authentication. It is opinionated and may not suit some usecases.
- TypeScript
- PostgreSQL with Prisma ORM
- Session authentication with express-sesssion and passport.js
- Redis store for persisting session data
First, create a .env file to let node access environment variables
# Only needed for development
touch .env
Then, add environment variables to .env
For DATABASE_URL
, see this Prisma guide
PORT=<port-number>
SESSION_SECRET=<your-session-secret>
REDIS_URL=<redis-server-url>
DATABASE_URL=<postgresql-server-url>
Make sure both PostgreSQL and Redis are running. Finally, install dependencies and start the server
# Install dependencies
yarn install
# Compile TypeScript source code into JavsScript and watch for changes
yarn watch
# Open a new terminal, start developing
yarn dev
This server is able to run on Heroku (free tier) via docker To deploy on Heroku, please make sure:
- You have Docker installed.
- You have a Heroku account and have Heroku Cli installed.
Then please follow this Heroku Guide. After creating the app by heroku create
, you need to install Heroku PostgreSQL and Redis addons for the app to work properly:
There aren't any tests yet. However, Jest should work great with this project.