A sophisticated TODO list application built with Node.js 18 and Express 4.x, featuring a SQLite local database, full CRUD API, a responsive dark-themed UI, and comprehensive test coverage.
| Component | Technology | Version |
|---|---|---|
| Runtime | Node.js | 18.x LTS |
| Framework | Express.js | 4.18.x |
| Database | SQLite (via better-sqlite3) | 9.x |
| Templating | EJS | 3.x |
| Validation | express-validator | 7.x |
| Testing | Jest + Supertest | 29.x / 6.x |
| Linting | ESLint | 8.x |
- Full CRUD operations for TODO items
- Priority levels: low, medium, high, urgent
- Tags, due dates, and descriptions
- Search and filtering (by status, priority, tags)
- Sortable and paginated list view
- Stats dashboard (total, pending, completed, overdue)
- Toggle completion status
- Bulk delete completed items
- Input validation on all endpoints
- Rate limiting, CORS, Helmet security headers
- Responsive dark-themed UI
- SQLite database with WAL mode for performance
- Node.js 18.x (required — the app enforces this via
enginesinpackage.json) - npm (comes with Node.js)
- nvm (recommended for managing Node versions)
# Using nvm (recommended)
nvm install 18
nvm use 18
# Verify
node --version # Should show v18.x.xnpm install# Create the database and run migrations
npm run db:init
# (Optional) Seed with sample data
npm run db:seednpm run devNODE_ENV=production npm startThe app will start on http://localhost:3000 by default.
| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
Server port |
HOST |
0.0.0.0 |
Server host |
NODE_ENV |
development |
Environment (development/test/production) |
DB_PATH |
data/todo.db |
SQLite database file path |
RATE_LIMIT_WINDOW_MS |
900000 |
Rate limit window (ms) |
RATE_LIMIT_MAX |
100 |
Max requests per window |
CORS_ORIGIN |
* |
CORS allowed origin |
npm testnpm run test:coveragenpm run test:watchTests use a separate test database (data/todo-test.db) that is automatically created and cleaned up. The test suite covers:
- Create (POST): Valid creation, all fields, validation errors (missing title, invalid priority, bad dates, etc.)
- Read All (GET): Pagination, filtering by status/priority, search, sorting, validation of query params
- Read One (GET): Fetch by ID, 404 for missing, 400 for invalid UUID
- Update (PUT): Individual field updates, multi-field updates, timestamp changes, validation errors
- Toggle (PATCH): Toggle complete/incomplete, idempotency
- Delete One (DELETE): Successful deletion, verification of removal, 404 for missing
- Delete Completed (DELETE): Bulk deletion of completed items
- Stats (GET): Stats accuracy, count verification after operations
- Edge Cases: Large page numbers, XSS input, concurrent creates, tag filtering
# Check for lint errors
npm run lint
# Auto-fix lint errors
npm run lint:fix# Initialize database (create tables)
npm run db:init
# Seed database with sample data
npm run db:seed
# Reset database (delete and re-seed)
npm run db:resetGET /api/todos?page=1&limit=20&sort=created_at&order=DESC&completed=false&priority=high&search=keyword&tag=work
GET /api/todos/:id
POST /api/todos
Content-Type: application/json
{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"priority": "high",
"tags": ["shopping", "personal"],
"due_date": "2025-01-15"
}
PUT /api/todos/:id
Content-Type: application/json
{
"title": "Updated title",
"completed": true,
"priority": "urgent"
}
PATCH /api/todos/:id/toggle
DELETE /api/todos/:id
DELETE /api/todos
GET /api/todos/stats
.
├── README.md
├── package.json
├── jest.config.js
├── .eslintrc.json
├── .nvmrc
├── .gitignore
├── src/
│ ├── server.js # Entry point, starts HTTP server
│ ├── app.js # Express app configuration
│ ├── config/
│ │ └── index.js # Centralized configuration
│ ├── db/
│ │ ├── connection.js # SQLite connection manager
│ │ ├── migrate.js # Database migrations
│ │ ├── init.js # Database initialization
│ │ ├── seed.js # Sample data seeder
│ │ └── reset.js # Database reset utility
│ ├── models/
│ │ └── todo.js # Todo data model (CRUD operations)
│ ├── routes/
│ │ ├── api.js # REST API routes
│ │ └── views.js # View rendering routes
│ ├── middleware/
│ │ ├── errorHandler.js # Error handling middleware
│ │ └── validators.js # Request validation middleware
│ ├── views/
│ │ ├── index.ejs # Main page template
│ │ └── error.ejs # Error page template
│ └── public/
│ ├── css/
│ │ └── styles.css # Application styles
│ └── js/
│ └── app.js # Frontend JavaScript
└── tests/
└── api.test.js # API endpoint tests
MIT