Skip to content

REST API for a sandwich menu & ordering system – manage menu items,, orders & user sessions. Built with TypeScript & Bun.

Notifications You must be signed in to change notification settings

GR0UD/danskmetal-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dansk Metal API

A minimal REST API for managing users and menu sessions. Lightweight, middleware-driven TypeScript app (Bun/Node).

Users are identified by a username (or other identifier) and authenticate using a short numeric PIN — the project does not require or use email addresses.

Features

  • User creation and authentication (PIN codes)
  • Menu session management
  • Middleware for authentication, error handling and rate limiting

Tech

  • TypeScript
  • Bun (recommended) or Node.js
  • Minimal file-based structure under src/

Tech Stack

  • Runtime: Bun (recommended) or Node.js
  • Language: TypeScript
  • Authentication: JWT-based middleware (src/middleware/auth.ts)
  • Rate limiting: middleware in src/middleware/rateLimit.ts
  • Storage: check src/db.ts for the chosen adapter (DB connection is configurable)

Quick Start

Prerequisites: Bun (recommended) or a recent Node.js. Clone the repo and install dependencies:

bun install

Start the development server:

bun run dev
# or with npm / pnpm (if configured)

Open http://localhost:3000

Configuration

Create a .env file or export environment variables used by the app. Common variables:

  • PORT — port to bind (default: 3000)
  • DATABASE_URL — connection string for the database
  • JWT_SECRET — secret used by src/middleware/auth.ts for signing/verifying tokens
  • RATE_LIMIT_WINDOW / RATE_LIMIT_MAX — optional rate-limit settings

Check src/db.ts and src/middleware/auth.ts for exact expectations.

Project Structure

API (examples)

Below are the most common endpoints; see route files for full details and payload shapes.

  • POST /users — create a new user

    Notes: the password field is a PIN code (numeric, short). Users are identified by username (or another non-email identifier).

    Example:

    curl -X POST http://localhost:3000/users \
      -H "Content-Type: application/json" \
      -d '{"username":"alice","password":"1234"}'
  • POST /sessions — create a session / login

    Example:

    curl -X POST http://localhost:3000/sessions \
      -H "Content-Type: application/json" \
      -d '{"username":"alice","password":"1234"}'

Other routes and protected endpoints are implemented in src/routes/session.ts and src/routes/user.ts. Authentication is enforced by src/middleware/auth.ts.

Development notes

  • The app exposes middleware for error handling and rate limiting; review src/middleware to adjust behavior.
  • Models live in src/models and are small single-responsibility modules.

Contributing

Open an issue or submit a PR. Keep changes small and focused.

About

REST API for a sandwich menu & ordering system – manage menu items,, orders & user sessions. Built with TypeScript & Bun.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors