Skip to content

JamesDAdams/backend-express-template

Repository files navigation

Backend Express Template

License: MIT

express prisma swagger postman docker s3 Nodemailer bun

Base Express server template with Prisma ORM (v5), routing-controllers, JWT authentication, TypeScript, Swagger, Postman config, Docker, Email, S3, Logging, Bun, Worker, Batch

Features

Project structure

📦/ # Main folder
 ┣ 📂postman # The Postman config to import
 ┣ 📂docker # For launch the server and db in docker container
 ┣ 📂prisma # the SQL schema and migrations
 ┣ 📦src # Main folder of code
  ┣ 📂controllers # Folder for handlers functions called from routes
  ┣ 📂dtos # DTO pattern for handling data
  ┣ 📂exceptions # Global handle error
  ┣ 📂interfaces # Interfaces for greater abstraction
  ┣ 📂middleware # Folder for express middlewares
  ┣ 📂server # Express server instance with routing-controllers config
  ┣ 📂services # Services for write core code bussiness
  ┣ test # Unit test and Artillery test
  ┣ 📂utils # Utils for usage in the application
  ┗ 📜app.ts # Main file

Install

Install required packages with

bun install

Initial configuration

Create an .env file and setup the variables

cp .env.example .env

Migrate with prisma in order to create the required database tables

bun prisma:deploy

Development

While editing your code, you probably want to automatically build your application and watch for changes with nodemon, in order to achieve that, just run bun dev and bun dev:watch

Postman

You can import backend-express-template.postman_collection.json in your postman collections And workspace.postman_globals.json in your Environments

Docker

You can launch the server, the database and a smtp server in docker with this command (edit variable in the docker-compose.yml)

cd /docker
docker-compose up -d

Production

Build your application with bun build and then run it with bun start

ERROR

If you have this error : Module '"@prisma/client"' has no exported member 'User' run bun prisma generate

Licence

MIT

About

A template backend with Express, Prisma, Bun, JWT, TS, Swagger, S3, Email, Docker, Postman, Logging, Routing-controllers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages