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
- Copy environment variables:
cp .env.example .env- Install dependencies and run:
npm install
npm run dev- Open docs and explore the API (local):
Required environment variables
MONGO_URIβ MongoDB connection stringJWT_SECRETβ secret for access tokensJWT_REFRESH_SECRETβ secret for refresh tokensPORTβ optional (default7777)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 tokensGET /api/auth/meβ current authenticated userGET /api/usersβ list users (auth)POST /api/usersβ create user (owner only)
Tauri & Desktop integration notes
- For Tauri apps, call
POST /api/auth/loginand securely store therefresh_tokenandaccess_tokenin your app. Use the access token for API calls and callPOST /api/auth/refreshto rotate tokens when needed. - Set
CORS_ORIGINto 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.jsservers.urlpoints to your API root (no/docssuffix). - Ensure
CORS_ORIGINincludes the origin shown in the browserOriginheader. - Temporarily enable
DEBUG_CORS=trueto log requestOriginand response CORS headers.
- Ensure
Customization & Branding
src/loaders/swagger.jswiresswagger-customand exposes/swagger-customassets. Editsrc/loaders/swagger.jsto 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.