A comprehensive Express.js API server featuring categorized endpoints, authentication, todos, notes, URL shortener, and various utility services.
- Node.js (v16+ recommended)
- npm or yarn
- MongoDB (local or remote)
# Docker (recommended for development)
docker run -p 0.0.0.0:27017:27017 --name mongo-dev -d mongo:latest
# Or use MongoDB Atlas for cloud hostingnpm install
npm run startnpm install
npm run devCopy .env.sample to .env and configure:
# Server Configuration
PORT=1919
VERSION=1.9.2
TIMEZONE=America/New_York
# Authentication
JWT_SECRET=your-very-long-secret-key
# MongoDB Connections (separate databases for different features)
MONGODB_URI_API=mongodb://localhost/api?retryWrites=true&w=majority
MONGODB_URI_TODOS=mongodb://localhost/todo?retryWrites=true&w=majority
MONGODB_URI_NOTES=mongodb://localhost/notes?retryWrites=true&w=majority
MONGODB_URI_SHRTNR=mongodb://localhost/shrtnr?retryWrites=true&w=majority
# External APIs
GITHUB_API_KEY=your-github-token
HEADER_AGENT=YourApp/1.0 (+https://yoursite.com)
# Optional URLs
BLOG_URL=https://api.github.com/repos/user/repo/contents/_posts
DOMAIN_LIST=https://example.com/domains.jsonThe HEADER_AGENT environment variable sets the User-Agent header for
external API requests.
Why needed:
- Many APIs require User-Agent identification
- Used for rate limiting and monitoring
- Prevents blocked requests
- Good API etiquette
Recommended formats:
# Standard format
HEADER_AGENT="MyAPI/1.0 (+https://myapi.com)"
# GitHub Apps
HEADER_AGENT="MyGitHubApp/1.0"
# Personal projects
HEADER_AGENT="JohnsAPI/1.0 (john@example.com)"
# Company services
HEADER_AGENT="AcmeCorp-API/2.1 (+https://api.acmecorp.com)"Default value: API-Server/1.0 (+https://github.com/now-sh/api)
- Models (
/models/) - MongoDB schemas using Mongoose - Controllers (
/controllers/) - Business logic - Routes (
/routes/) - API endpoints with categorized structure - Middleware (
/middleware/) - Authentication, rate limiting, etc.
Multiple MongoDB databases for separation of concerns:
- API Database - Users, authentication tokens
- Todos Database - Todo items and lists
- Notes Database - Notes, gists, and documents
- Shortener Database - URL shortening service
API endpoints are organized into logical categories:
- π§ Utilities - Encoding, hashing, UUID, passwords, JWT, QR codes
- π οΈ Tools - Commit generators, development utilities
- π Data - External APIs, time zones, domains
- βοΈ Health - COVID data, monitoring endpoints
- π€ Personal - Notes, todos, user management
- π Services - URL shortener, authentication
- Never-expiring tokens (configurable)
- Token rotation for security
- Revocation support (individual or all tokens)
- Database tracking of all tokens
GET /api/v1/auth # Authentication info
POST /api/v1/auth/signup # Create account
POST /api/v1/auth/login # Login
GET /api/v1/auth/me # Get user info
PUT /api/v1/auth/update # Update profile
POST /api/v1/auth/rotate # Rotate token
GET /api/v1/auth/tokens # List active tokens
POST /api/v1/auth/revoke # Revoke token(s)
POST /api/v1/auth/revoke-all # Revoke all tokens
# Sign up
curl -X POST /api/v1/auth/signup \
-H "Content-Type: application/json" \
-d '{"name":"John","email":"john@example.com","password":"secure123"}'
# Use token in requests
curl -H "Authorization: Bearer YOUR_TOKEN" /api/v1/auth/me
# Rotate token for security
curl -X POST /api/v1/auth/rotate \
-H "Authorization: Bearer YOUR_CURRENT_TOKEN"- Public by default (can be made private)
- Authentication required for creation/modification
- No auth needed for reading public todos
- Features: tags, priorities, due dates, completion tracking
- Google Keep + GitHub Gists style
- Public by default (can be made private)
- Multiple content types: text, markdown, code
- Features: syntax highlighting, collaboration, pinning, attachments
- Custom aliases and expiration dates
- Click tracking and statistics
- Public/private URLs
- User-owned URLs with authentication
- Base64 encode/decode (
/utilities/base64) - Hashing (MD5, SHA1, SHA256, SHA512) (
/utilities/hash) - UUID generation (
/utilities/uuid) - Password generation (
/utilities/passwd) - JWT decoding/validation (
/utilities/jwt) - QR Code generation (
/utilities/qr) - Color conversion (
/utilities/color) - Lorem Ipsum generation (
/utilities/lorem)
- Commit Generator (
/tools/commit)
- Time zones (
/data/timezones) - Domains (
/data/domains) - School closings (
/data/closings)
- COVID data (
/health/disease) - Global stats (
/health/global)
- Todos management (
/personal/todos) - Notes management (
/personal/notes)
- URL Shortener (
/services/url)
All original endpoints remain available for backward compatibility:
/api/v1/base64β/api/v1/utilities/base64/api/v1/hashβ/api/v1/utilities/hash- etc.
- GitHub integration (
/api/v1/git) - Anime quotes (
/api/v1/anime) - Version info (
/api/v1/version) - API Help (
/api/help)
- Rate limiting with express-rate-limit
- Input validation with express-validator
- CORS support
- Helmet security headers
- Password hashing with bcrypt
- Token blacklisting/revocation
- Request timeout protection
npm run start # Production server
npm run dev # Development with nodemon
npm run lint # ESLint code checking
npm run commit # Automated git commits- JavaScript codebase with CommonJS modules
- Express.js with modular router architecture
- VS Code integration with proper settings
- ESLint for code quality and consistency
All external requests include 5-second timeouts and proper error handling:
- GitHub API - with pagination support
- Cheerio scraping - with timeout wrapper
- Axios/Fetch - with timeout utilities
Visit /api/docs for interactive Swagger documentation when the server is running.
{
"success": true,
"data": { ... },
"errors": []
}{
"success": false,
"error": "Error message",
"errors": [
{"field": "email", "message": "Invalid email format"}
]
}The GitHub API endpoints automatically handle pagination to fetch all results:
- Fetches multiple pages automatically
- Combines results from all pages
- Handles rate limiting appropriately
- Returns complete datasets
- Set all required environment variables
- Ensure MongoDB connections are accessible
- Configure external API keys (GitHub, etc.)
- Use PM2 or similar for process management
- Set up reverse proxy (nginx)
- Configure SSL certificates
- Monitor database connections
- Set up logging and monitoring
- Follow the existing code style
- Use TypeScript for new features
- Add proper error handling
- Include input validation
- Update documentation
MIT
Jason Hempstead
π₯ Pro Tip: Use the /help endpoint on any route to see available
options and examples!