Skip to content

A high-performance Node.js backend boilerplate built with Fastify, Drizzle ORM, PostgreSQL, and JWT Authentication.

Notifications You must be signed in to change notification settings

emranweb/node-fastify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-fastify

A powerful and modular Fastify-based backend boilerplate featuring secure authentication, PostgreSQL database management with Drizzle ORM, and automated Swagger documentation.

🚀 Features

  • Fastify Framework: High-performance, low-overhead web framework.
  • Authentication: JWT-based security with password hashing via bcrypt.
  • Drizzle ORM: Type-safe and lightweight ORM for PostgreSQL.
  • Swagger Documentation: Interactive API testing interface at /docs.
  • Environment Management: Flexible configuration using .env.
  • Pretty Logging: Colorful and minimal logs in development using pino-pretty.

🛠️ Tech Stack

📦 Installation

  1. Clone the repository:

    git clone https://github.com/emranweb/node-fastify.git
    cd node-fastify
  2. Install dependencies:

    yarn install
    # or
    npm install
  3. Setup Environment Variables: Create a .env file in the root directory and add your credentials:

    PORT=4000
    DATABASE_URL=postgresql://user:password@localhost:5432/db_name
    JWT_SECRET=your_super_random_secret_here

🗄️ Database Setup

Ensure your PostgreSQL server is running. Use Drizzle Kit to push your schema to the database:

npx drizzle-kit push

🏃 Running the App

Development Mode (with auto-reload)

yarn dev

Production Mode

yarn start

📖 API Documentation

Once the server is running, you can access the interactive Swagger documentation at: http://localhost:4000/docs

Key Endpoints:

  • POST /auth/register: Create a new user account.
  • POST /auth/login: Authenticate and receive a JWT token.
  • GET /users/me: (Protected) Get current user profile data.

🔒 Security

To access protected routes (/users/*), you must include the JWT token in the request header: Authorization: Bearer <YOUR_TOKEN>

📄 License

This project is ISC licensed.

About

A high-performance Node.js backend boilerplate built with Fastify, Drizzle ORM, PostgreSQL, and JWT Authentication.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published