Skip to content

vpsop/BackendCore

Repository files navigation

BackendCore

BackendCore is a Node.js backend template built with Express and TypeScript for my personal use. It provides a clean, scalable architecture with built-in support for request validation, structured logging, environment configuration, and Docker-based deployment.


Features

  • TypeScript-first development
  • Zod v4 validation (type-safe request validation)
  • Structured logging with request tracing
  • Environment validation using Zod
  • Clean architecture (Route → Controller → Service)
  • Centralized error handling
  • Dockerized setup for easy deployment
  • Scalable modular structure

Setup

1. Install dependencies

npm install

2. Configure environment

Create a .env file:

PORT=5000
NODE_ENV=development
LOG_LEVEL=info

3. Run in development

npm run dev

Docker [TODO]

Build and run with Docker

docker-compose up --build

Validation

Request validation is handled using Zod:

  • Ensures type safety
  • Sanitizes input
  • Prevents invalid data from reaching controllers

Logging

  • Structured JSON logs
  • Request-level tracing with requestId
  • Separate error and combined logs

Safe Environment Variables

  • All environment variables are validated at startup
  • App fails fast on invalid configuration

Architecture

  • Routes: define endpoints + middleware
  • Controllers: handle HTTP layer
  • Services: contain business logic

Goals

  • Reduce setup time for new services
  • Enforce consistency across projects
  • Provide a scalable backend foundation

About

BackendCore is a Node.js (Express + TypeScript) backend template with built-in validation, logging, and scalable architecture.

Topics

Resources

Stars

Watchers

Forks

Contributors