CoreServe is a modular Node.js backend starter designed to give REST API projects a clean, maintainable foundation. It ships with authentication, API key protection, score endpoints, caching hooks, and a straightforward MVC-style structure.
- Modular MVC-inspired architecture
- JWT-based authentication
- API key authorization with plan-based rate limiting
- MariaDB integration through environment variables
- Redis-backed response caching with graceful fallback
- Jest and Supertest coverage for core HTTP flows
- Node.js 18 or newer
- MariaDB or MySQL
- Redis (optional, but recommended for caching)
- Clone the repository:
git clone https://github.com/Vikbg/CoreServe.git
cd CoreServe- Install dependencies:
pnpm install- Create a
.envfile in the project root:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=coreserve
DB_NAME_TEST=coreserve_test
JWT_SECRET=replace_this_with_a_secure_secret
JWT_EXPIRES_IN=1h
PORT=3000
HOST=0.0.0.0
REDIS_URL=redis://localhost:6379
CORS_ORIGIN=http://localhost:3000
JSON_LIMIT=10kb- Start the server:
pnpm startThe API will be available at http://localhost:3000 unless you configure a different host or port.
pnpm start
pnpm dev
pnpm test
pnpm lintCoreServe/
├── config/ # Shared configuration constants
├── controllers/ # Route handlers and application logic
├── docs/ # Project documentation
├── middlewares/ # Authentication, validation, and caching layers
├── models/ # Database access helpers
├── routes/ # Express route definitions
├── tests/ # Integration test suite
├── utils/ # Shared utilities such as logging
├── db.js # MariaDB connection pool
├── index.js # App factory and server bootstrap
├── redisClient.js # Redis connection and cache helpers
└── package.json # Scripts and dependencies
POST /players/register: Create a new user accountPOST /players/login: Authenticate and receive a JWTGET /players/me: Fetch the authenticated user profileGET /scores/leaderboard: Fetch the global leaderboardPOST /scores: Submit the authenticated user's scoreGET /scores/:id: Fetch the authenticated user's score history
See docs/api.md for full request and response examples.
Contributions are welcome. Start with CONTRIBUTING.md, keep changes focused, and make sure tests pass before opening a pull request.
If you discover a security issue, follow the reporting guidance in SECURITY.md.
This project is released under the MIT License. See LICENSE for details.