Skip to content

SergioNR/express-js-template

Repository files navigation

express-js-template

Overview

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

Table of contents

Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

Node.js

  • NodeJS - This template is designed to work with node version 22.14.0

Docker & Docker Compose

We use docker compose from Docker to setup the services for development environment.

Installation

npm and Node.js dependencies

Install dependencies:

npm install

Running Locally

Set up environment variables

We use Node's inbuilt env variables injection via process.env.VARIABLE_NAME syntax

Copy the .env.example file and configure each variable

Start Docker services

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:docker

This 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

User Analytics

This template uses Posthog Node for comprehensive user analytics

Logging

We use Pinojs for logging which uses transports to record logs - Currently configured transports are:

Log Visualization

This template uses Betterstack to visualize logs - Modify as required

Recommended third-party tools

  • 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

Security

Request slowing & limiting

To guarantee API resilence and provide protection against attacks, the following has been implemented

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •