This is a template for an ExpressJS server. It includes a project agnostic setup that will allow you to focus on business-related programming
This template is the backend part of a P/MERN template - paired with ReactJs Template
Before you begin, ensure you have the following installed:
- NodeJS - This template is designed to work with
node version 22.14.0
We use docker compose from Docker to setup the services for development environment.
- For MacOS: Grab the docker mac installation from the Docker website
Install dependencies:
npm installWe use Node's inbuilt env variables injection via process.env.VARIABLE_NAME syntax
Copy the .env.example file and configure each variable
If you installed Docker Desktop (on a Mac or Windows machine), you can run the following command to start the Docker services:
npm run start:dockerThis will run docker compose up --build --watch which will start the backend and the PostgreSQL database
Note: for practicality, the database credentials for the local environment are hardcoded in the compose.yaml file
The application will now be reachable on http://localhost:3000
This template uses Posthog Node for comprehensive user analytics
We use Pinojs for logging which uses transports to record logs - Currently configured transports are:
This template uses Betterstack to visualize logs - Modify as required
- PostgreSQL Database
- This template is using Supabase free tier to host a free PostgreSQL database. This can be enough for a dev env workload but production workload will require updatingw
- Koyeb Deployment
- This template is using Koyeb for deployments - Its pretty affordable and has autoscaling to 0 to save costs
To guarantee API resilence and provide protection against attacks, the following has been implemented
- express-rate-limit
- Helps with brute force attacks, DDoS, Scraping & API abuse
- express-slow-down
- Gives the server breathing room under heavy load