Skip to content

typist1/mses-backend

 
 

Repository files navigation

Backend Template

2026 Discover Program Project Templates

This template was created by the DISC tech leads of 2025-2026:

Check out DISC:

Stack

Firebase Authentication + Supabase (PostgreSQL) backend template. Can be migrated to AWS RDS (MySQL) — see SETUP_GUIDE.md.

  • Runtime: Node.js with ES Modules
  • Framework: Express.js
  • Authentication: Firebase Auth (Email/Password + Google OAuth)
  • Database: Supabase (PostgreSQL) — switchable to AWS RDS (MySQL)
  • Database Client: pg / mysql2 (connection pool, raw SQL with parameterized queries)
  • Language: JavaScript (ES Modules)

Quick Start

# Install dependencies
npm install

# Set up environment
cp .env.example .env
# Edit .env with your Firebase credentials and Supabase DATABASE_URL

# Create tables — paste sql/create_tables.sql into the Supabase SQL Editor

# Start development server
npm run dev

See SETUP_GUIDE.md for full setup instructions.

API Endpoints

  • POST /auth/signup - Create new user
  • POST /auth/login - Login with Firebase ID token
  • GET /auth/me - Get current user
  • GET /auth/profile - Get current user (alias for /me)
  • GET /auth/users - Get all users (protected)
  • POST /auth/logout - Logout
  • POST /auth/token - Sync Firebase OAuth user to database

Scripts

npm run dev     # Start development server
npm run lint    # Run ESLint
npm run format  # Format all files with Prettier

Editor Setup (VSCode)

When you open this project in VSCode, it will automatically prompt you to install the recommended extensions from .vscode/extensions.json. Click Install on the notification, or install them manually:

  1. Prettier ESLint (rvest.vs-code-prettier-eslint) — formats your code using both Prettier and ESLint rules on every save
  2. ESLint (dbaeumer.vscode-eslint) — shows lint errors and warnings inline as you type

Once both are installed, restart VSCode completely (quit and reopen). Every file save will automatically format and lint your code. Format-on-save is configured in .vscode/settings.json — do not edit this file.

To manually format all files at once:

npm run format

Configuration

Required .env variables (see .env.example):

  • FIREBASE_SERVICE_ACCOUNT_KEY - Firebase service account JSON
  • DATABASE_URL - Supabase PostgreSQL connection string
  • PORT - Server port (default: 5050)
  • FRONTEND_URL - Production frontend URL for CORS
  • FRONTEND_URL_DEV - Development frontend URL for CORS
  • NODE_ENV - Environment (development/production)

rds-config.ini is only needed when migrating to AWS RDS. See SETUP_GUIDE.md.

Project Structure

js-backend/
├── sql/
│   ├── create_tables.sql          # Supabase / PostgreSQL schema (default)
│   └── create_tables_mysql.sql    # AWS RDS / MySQL schema (for migration)
├── src/
│   ├── config/
│   │   ├── firebase.js            # Firebase Admin SDK
│   │   └── database.js            # DB connection pool (Supabase default)
│   ├── controllers/
│   │   └── authController.js      # Auth endpoint logic
│   ├── middleware/
│   │   └── authMiddleware.js      # Firebase token verification
│   ├── providers/
│   │   ├── postgresProvider.js    # Supabase / PostgreSQL queries (default)
│   │   └── mysqlProvider.js       # AWS RDS / MySQL queries (for migration)
│   ├── repositories/
│   │   └── userRepository.js      # Adapter — swap providers here
│   ├── routes/
│   │   └── authRoutes.js          # API routes
│   └── server.js                  # Express app
├── .env.example                   # Environment template
├── rds-config.ini.example         # AWS RDS config template (for migration)
└── package.json

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%