A lightweight backend project built with Node.js and TypeScript, featuring both REST and GraphQL APIs.
Features • Tech Stack • Getting Started • API Docs
This project is an example of a backend server that exposes the same application through REST and GraphQL. It includes user authentication, post management, pagination, and several measures to help protect the API from abuse.
- Authentication — user registration and cookie-based sessions
- Post management — create, retrieve, and delete posts
- Pagination — retrieve posts in configurable pages
- Rate limiting — limit repeated requests
- GraphQL query depth protection — guard against deeply nested queries
- Input validation — request validation with Zod
- API documentation — interactive REST documentation with Swagger UI
| Technology | Purpose |
|---|---|
| Node.js | JavaScript runtime |
| Express | HTTP server and REST endpoints |
| TypeScript | Static typing |
| GraphQL & Apollo Server | GraphQL API |
| SQLite | Database |
| Zod | Input validation |
| Swagger / OpenAPI | REST API documentation |
- Node.js
- npm
git clone <your-repository-url>
cd <repository-folder>
npm installCreate a .env file with the environment variables required by the project, then start the server using the appropriate script from package.json.
Once the server is running, open Swagger UI:
Local URL: http://localhost:3000/api-docs
src/
├── doc/ # OpenAPI configuration
├── graphql/ # GraphQL server and context
├── http/ # API routing
├── modules/ # Auth and posts modules
└── shared/ # Shared utilities and errors
Built as a hands-on project to explore REST, GraphQL, and backend API security.