Manage users, publish articles, and track page views with blazing-fast, secure, and scalable REST API — all powered by TypeScript, Node.js, Express, and MongoDB.
- Production-Ready: Battle-tested architecture for real-world apps.
- Secure by Design: Robust authentication, password hashing, and rate-limiting keep your platform safe.
- Extensible & Easy to Integrate: RESTful API structure, perfect for any modern frontend framework.
- Real-Time Analytics: Track page views and understand your audience instantly.
-
User Management
Effortlessly create, update, and delete users with industry-standard security. -
JWT Authentication
Login, protect routes, and manage sessions with ease. -
Dynamic Article Publishing
Write, edit, and manage articles — draft or publish in just a click. -
Page View Insights
Detailed tracking and analytics to help you grow your content. -
Rock-Solid Security
Rate limiting, CORS controls, and bcrypt password hashing out-of-the-box.
- TypeScript (static typing, safer code)
- Node.js & Express (ultra-fast service layer)
- MongoDB + Mongoose (flexible NoSQL database, rapid iteration)
- JWT for secure authentication flows
- REST JSON APIs scaffolded for clarity and maintainability
- Node.js (v14+)
- MongoDB (v4+)
- npm or yarn
-
Clone & Enter the Project
git clone https://github.com/yourusername/cms-rest.git cd cms-rest -
Install Dependencies
npm install
-
Set Up Environment Variables
cp .env.example .env # Edit .env as needed -
Start MongoDB
Most easily via Docker Compose (recommended):docker-compose up
Or, for manual DB setup, read MongoDB Initialization Instructions.
-
Run the Development Server
npm run dev # Now live at http://localhost:3000 🚀
- Production Build
npm run build
- Start Production Server
npm start
Quickly populate your database with sample data for development and testing:
-
Run Seeder (Development)
npm run seed
This will clear existing data and seed the database with sample users, articles, and page views.
-
Run Seeder (Production)
npm run build npm run seed:prod
-
Seeding Options
# Explicitly clear existing data (default behavior) npm run seed:clear # Keep existing data and add seed data npm run seed:no-clear
The seeder creates:
- Users: 5 sample users including an admin and regular users (all with password:
password123, admin:admin123) - Articles: 10 sample articles (mix of published and draft) distributed among users
- Page Views: Random page views for published articles over the last 30 days
This makes it easy to test and develop features without manually creating test data.
POST /auth/login— Login with username & passwordPOST /auth/logout— Logout
GET /user— Browse all usersGET /user/:id— Fetch user by IDPOST /user— Create a new user (authenticated)PATCH /user/:id— Update current user profileDELETE /user/:id— Remove user account
GET /article— List all published articlesGET /article/me— List articles by current userGET /article/:id— Read a specific articlePOST /article— Publish a new articlePATCH /article/:id— Edit your articleDELETE /article/:id— Delete your article
POST /page-view— Record an article viewGET /page-view/count— Aggregate page viewsGET /page-view/aggregate-date— Breakdown page views by date
| 🧑💻 User | 📄 Article | 👁️ PageView |
|---|---|---|
| id | id | id |
| name | status | article |
| username | title | viewedAt |
| passwordHash | content | |
| createdAt | user | |
| updatedAt | createdAt | |
| updatedAt |
- Hashed Passwords (bcrypt)
- JWT Auth with Expiry
- Rate Limiting (anti-brute-force)
- Flexible CORS
- Strict Input Validation
Spin up everything in seconds:
docker-compose up- Pre-configured MongoDB: Collections, performance indexes, sample admin & article.
- Turnkey Demo: Start experimenting right away.
Clone, run, and start building today! 🚀