Skip to content

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Open-Source-Backend β€” Modern, secure, and extensible API backend

Welcome to Open-Source-Backend β€” a production-ready Node.js backend built for desktop/web apps and Tauri integrations. Fast to start, secure by design, and designed to be customized.

Why you'll love it

  • Clean JWT auth with rotating refresh tokens (access: short-lived, refresh: long-lived)
  • Role-based access controls (owner/admin) and user management API ready
  • Swagger-driven API docs with optional visual customization via swagger-custom
  • Minimal, well-structured codebase: Express + Mongoose + modular loaders

Feature highlight β€” Swagger custom UI This project integrates swagger-custom to give your API documentation a polished, branded UI. Learn more and star the project:

Quickstart

  1. Copy environment variables:
cp .env.example .env
  1. Install dependencies and run:
npm install
npm run dev
  1. Open docs and explore the API (local):

http://localhost:7777/docs

Required environment variables

  • MONGO_URI β€” MongoDB connection string
  • JWT_SECRET β€” secret for access tokens
  • JWT_REFRESH_SECRET β€” secret for refresh tokens
  • PORT β€” optional (default 7777)
  • CORS_ORIGIN β€” allowed origins (comma-separated)

Core endpoints (summary)

  • POST /api/auth/login β€” returns { access_token, refresh_token, user }
  • POST /api/auth/refresh β€” rotate and return new tokens
  • GET /api/auth/me β€” current authenticated user
  • GET /api/users β€” list users (auth)
  • POST /api/users β€” create user (owner only)

Tauri & Desktop integration notes

  • For Tauri apps, call POST /api/auth/login and securely store the refresh_token and access_token in your app. Use the access token for API calls and call POST /api/auth/refresh to rotate tokens when needed.
  • Set CORS_ORIGIN to your app origin when serving docs or using the UI in-browser.

Debugging CORS / Docs

  • If Swagger UI shows "Failed to fetch":
    • Ensure src/swagger/index.js servers.url points to your API root (no /docs suffix).
    • Ensure CORS_ORIGIN includes the origin shown in the browser Origin header.
    • Temporarily enable DEBUG_CORS=true to log request Origin and response CORS headers.

Customization & Branding

  • src/loaders/swagger.js wires swagger-custom and exposes /swagger-custom assets. Edit src/loaders/swagger.js to change colors, site title, or custom JS/CSS.

Contribution

  • Pull requests welcome. Please keep changes small and focused. For large refactors, open an issue first to discuss.

License

  • MIT β€” use freely and contribute back ❀️

Repository

Enjoy β€” if you want, I can add README badges (build, npm version, license) and a short example integration snippet for Tauri or React.

Releases

Packages

Contributors

Languages