Skip to content

About

A secure Node.js authentication backend built with Express.js, JWT, Express Validator, and middleware featuring user registration, login, protected routes, and token-based authentication.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodejs-auth-boilerplate

A secure Node.js authentication starter built with Express.js, JWT, and a lightweight local database store so the project can run even without a local Postgres installation.

Database setup

The app now uses a local JSON file database at Backend/database/auth-store.json by default. This keeps the project portable for demos and open-source sharing.

If you want to use PostgreSQL instead, set a DATABASE_URL in Backend/.env and the app will connect to it automatically.

SQL schema for PostgreSQL

If you later connect to PostgreSQL, create the users table with:

CREATE TABLE users (
  id BIGSERIAL PRIMARY KEY,
  full_name VARCHAR(150) NOT NULL,
  email VARCHAR(255) NOT NULL UNIQUE,
  password_hash TEXT NOT NULL,
  is_active BOOLEAN DEFAULT TRUE,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Run locally

  1. Install dependencies in the backend and frontend folders.
  2. Start the backend:
    cd Backend
    npm run dev
  3. Start the frontend:
    cd Frontend
    npm run dev

Notes

  • The local database file is created automatically on first run.
  • The UI has been refreshed with a dark theme for a modern look.
  • When a user is already authenticated, the app keeps them on the success screen instead of allowing them to return to login until they log out.

About

A secure Node.js authentication backend built with Express.js, JWT, Express Validator, and middleware featuring user registration, login, protected routes, and token-based authentication.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages