This API provides a comprehensive set of endpoints organized into categories, with consistent JSON/text response patterns and function-based validation middleware. The project includes both RESTful API endpoints and a full frontend interface using EJS templating.
- Production:
https://api.casjay.coffee - Development:
http://localhost:2000
All endpoints are prefixed with /api/v1
The /api endpoint returns comprehensive help with all available routes organized by category:
curl -q -LSsf https://api.casjay.coffee/apiResponse includes:
- Tools: Base64, Hash, UUID, JWT, QR Code, Color, Lorem, Password, Commit, Markdown, Cron, Regex, Diff, Dictionary
- Me: Blog, Domains, Info
- Data: Todos, Notes, URLs
- Fun: Jokes, Facts, Trivia, Anime
- Social: Blogs, GitHub, Reddit
- World: Covid, Disease, Closings, Timezones, USA, NYS, ArcGIS
- Auth: Login, Register, Profile
- Server: Version, Health, Cache, Docs, Debug
All endpoints support dual response formats:
- JSON (default): Returns structured JSON with
success,data, and optionalerrorfields - Text: Returns plain text by appending
/textto most endpoints
{
"success": true,
"data": {
// Response data
}
}{
"success": false,
"error": "Error message",
"details": "Additional error details (optional)"
}Developer utilities and generators.
POST /api/v1/tools/base64/encode- Encode text to Base64POST /api/v1/tools/base64/encode/text- Encode text to Base64 (text response)POST /api/v1/tools/base64/decode- Decode Base64 to textPOST /api/v1/tools/base64/decode/text- Decode Base64 to text (text response)GET /api/v1/tools/base64/help- Get help information
POST /api/v1/tools/hash/:algorithm- Generate hash (md5, sha1, sha256, sha512)POST /api/v1/tools/hash/:algorithm/text- Generate hash (text response)POST /api/v1/tools/hash/:algorithm/verify- Verify hashPOST /api/v1/tools/hash/:algorithm/batch- Generate hashes for multiple textsGET /api/v1/tools/hash- Get help information
GET /api/v1/tools/uuid/v4- Generate single UUID v4GET /api/v1/tools/uuid/v4/text- Generate UUID (text response)GET /api/v1/tools/uuid/generate/:count?- Generate multiple UUIDsPOST /api/v1/tools/uuid/generate- Generate with optionsGET /api/v1/tools/uuid/validate/:uuid- Validate UUIDGET /api/v1/tools/uuid- Get help information
POST /api/v1/tools/jwt/decode- Decode JWT tokenPOST /api/v1/tools/jwt/decode/text- Decode JWT (text response)GET /api/v1/tools/jwt- Get help information
POST /api/v1/tools/qr/generate- Generate QR code (base64/ascii)POST /api/v1/tools/qr/generate/text- Generate QR code (ASCII art)GET /api/v1/tools/qr/generate/image/:text- Generate QR code imageGET /api/v1/tools/qr- Get help information
POST /api/v1/tools/color/convert- Convert between color formatsPOST /api/v1/tools/color/palette- Generate color paletteGET /api/v1/tools/color/info- Get color informationGET /api/v1/tools/color- Get help information
GET /api/v1/tools/lorem/:type?/:count?- Generate lorem ipsumGET /api/v1/tools/lorem/text/:type?/:count?- Generate (text response)GET /api/v1/tools/lorem- Get help information
GET /api/v1/tools/passwd/:length?- Generate passwordGET /api/v1/tools/passwd/:length?/text- Generate password (text)POST /api/v1/tools/passwd/check- Check password strengthGET /api/v1/tools/passwd/batch/:count/:length?- Generate multipleGET /api/v1/tools/passwd- Get help information
GET /api/v1/tools/commit- Get random commit messageGET /api/v1/tools/commit/text- Get commit message (text)GET /api/v1/tools/commit/batch/:count- Get multiple messagesGET /api/v1/tools/commit/help- Get help information
POST /api/v1/tools/markdown/to-html- Convert markdown to HTMLPOST /api/v1/tools/markdown/to-markdown- Convert HTML to markdownPOST /api/v1/tools/markdown/preview- Preview markdown as HTML pageGET /api/v1/tools/markdown- Get help information
Legacy endpoints maintained for backward compatibility. These proxy to the new /tools endpoints.
Personal information endpoints. These return raw data without success/error wrappers.
GET /api/v1/me/info/profile- Get profile data from GitHubGET /api/v1/me/info/profile/text- Get profile (text format)GET /api/v1/me/info/domains- Get domain list from GitHubGET /api/v1/me/info/domains/text- Get domains (text format)GET /api/v1/me/info/resume- Get resume JSON from GitHubGET /api/v1/me/info/resume/text- Get resume (text format)GET /api/v1/me/info/resume/view- View resume PDF in browserGET /api/v1/me/info/resume/download- Download resume PDFGET /api/v1/me/info/github- Get my GitHub profile (casjay)GET /api/v1/me/info/github/repos- Get my GitHub repositoriesGET /api/v1/me/info/github/orgs- Get my GitHub organizationsGET /api/v1/me/info/reddit- Get my Reddit profile (casjay)GET /api/v1/me/info- Help/index endpoint
Data storage and retrieval endpoints.
GET /api/v1/data/blogs- Get all blog postsGET /api/v1/data/blogs/list- Get all blog posts (with full metadata)GET /api/v1/data/blogs/post/:slug- Get single blog post with HTML contentGET /api/v1/data/blogs/post/:slug/text- Get blog post as plain textGET /api/v1/data/blogs/search?q=query- Search blog postsGET /api/v1/data/blogs/help- Get help information
GET /api/v1/data/todos- Get user's todos (requires auth)POST /api/v1/data/todos- Create new todoPUT /api/v1/data/todos/:id- Update todoDELETE /api/v1/data/todos/:id- Delete todoGET /api/v1/data/todos/public- Get public todos
GET /api/v1/data/notes- Get user's notes (requires auth)GET /api/v1/data/notes/:id- Get specific notePOST /api/v1/data/notes- Create new notePUT /api/v1/data/notes/:id- Update noteDELETE /api/v1/data/notes/:id- Delete noteGET /api/v1/data/notes/list- Get public notes list
POST /api/v1/data/urls/shorten- Create short URLGET /api/v1/data/urls/:code- Redirect to original URLGET /api/v1/data/urls/stats/:code- Get URL statisticsDELETE /api/v1/data/urls/:code- Delete short URLGET /api/v1/data/urls- Get help information
Entertainment endpoints.
GET /api/v1/fun/anime/quote- Get random anime quoteGET /api/v1/fun/anime/quote/text- Get quote (text)GET /api/v1/fun/anime/quotes/:count- Get multiple quotesGET /api/v1/fun/anime- Get help information
Social media integrations.
GET /api/v1/social/github/user/:username- Get GitHub user profileGET /api/v1/social/github/user/:username/repos- Get user's repositoriesGET /api/v1/social/github/user/:username/orgs- Get user's organizationsGET /api/v1/social/github/repos/:owner/:repo- Get repository detailsGET /api/v1/social/github/orgs/:org- Get organization detailsGET /api/v1/social/github/orgs/:org/repos- Get org repositories
GET /api/v1/social/reddit/u/:username- Get Reddit user postsGET /api/v1/social/reddit/r/:subreddit- Get subreddit postsGET /api/v1/social/reddit/r/:subreddit/top- Get top posts
Global information endpoints.
GET /api/v1/world/covid- Get global COVID-19 statisticsGET /api/v1/world/covid/countries- Get all countries dataGET /api/v1/world/covid/countries/:country- Get specific countryGET /api/v1/world/covid/usa- Get USA statisticsGET /api/v1/world/covid/usa/:state- Get state statisticsGET /api/v1/world/covid/usa/ny- Get NY state statistics
GET /api/v1/world/timezones- Get all timezonesGET /api/v1/world/timezones/:timezone- Get specific timezoneGET /api/v1/world/timezones/search/:query- Search timezones
GET /api/v1/world/closings- Get school closingsGET /api/v1/world/closings/:state- Get state closings
User authentication and management.
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- Login userPOST /api/v1/auth/logout- Logout userGET /api/v1/auth/profile- Get user profile (requires auth)PUT /api/v1/auth/profile- Update profilePOST /api/v1/auth/refresh- Refresh auth tokenGET /api/v1/auth- Get help information
Server information and health endpoints.
GET /api/v1/version- Get server version and status informationGET /api/healthz- Health check endpoint (always returns 200, status in body)GET /api/v1/cache- Cache managementGET /api/v1/docs- Swagger documentationGET /api/v1/debug- Debug information (development only)
Maintained for backward compatibility with casjay.coffee frontend.
GET /api/v1/git- Proxy to/api/v1/me/info/githubGET /api/v1/git/jason- Proxy to/api/v1/me/info/githubGET /api/v1/git/user/:username- Proxy to GitHub user endpointGET /api/v1/git/repos/:username- Proxy to GitHub repos endpointGET /api/v1/git/orgs/:username- Proxy to GitHub orgs endpoint
The API includes a full frontend interface using EJS templating with Bootstrap 5 (Darkly theme).
/- Homepage with all service categories ("My Data" section displayed first)/utilities/base64- Base64 encoder/decoder/utilities/hash- Hash generator (MD5, SHA1, SHA256, SHA512)/utilities/uuid- UUID generator/utilities/jwt- JWT decoder/utilities/qr- QR code generator/utilities/color- Color converter/utilities/lorem- Lorem ipsum generator/utilities/passwd- Password generator/tools/commit- Git commit message generator/data/git- GitHub data viewer/data/reddit- Reddit activity viewer/data/covid- COVID-19 statistics/fun/anime- Anime quotes/data/domains- Domain list (displays domains and subdomains in separate sections with copy functionality)/data/timezones- World timezones/data/closings- School closings/data/blogs- Blog posts list/data/blogs/:slug- Single blog post (renders markdown as HTML)/personal/todos- Todo manager (requires auth)/personal/notes- Note manager (requires auth)/services/url- URL shortener (requires auth)/auth- Authentication page
- Consistent layout with navigation menu
- Dark/Light theme toggle with localStorage persistence
- Dark theme default (Bootswatch Darkly)
- Form-based interactions for all tools
- Real-time results display
- Copy-to-clipboard functionality with fallback
- Mobile-responsive design
- Global JavaScript Utilities (
utils.js) - Type-safe helper functions loaded on all pages:ensureString(),ensureArray()- Type safetyescapeHtml()- XSS protectionsafeGet()- Safe nested property accesscopyToClipboard()- Clipboard with automatic fallback and feedbackdebounce()- Function call debouncingformatDate()- Consistent date formattingshowLoading(),showError(),showSuccess()- State management
- Page-specific JavaScript files:
theme.js- Dark/light theme toggle with localStorageutility-forms-v2.js- Handles utility form submissionsdata-forms.js- Handles data viewing formsbase64.js- Base64 specific functionalitytodos.js- Todo managementcopy.js- Copy to clipboard utilityauth-cookies.js- Authentication helpers
formatSuccess(data)- Format successful responsesformatError(message, details)- Format error responsessendJSON(res, data, status)- Send JSON responsesendText(res, text, status)- Send text response
validateBase64Input- Validate base64 encoding/decoding inputvalidateHashInput- Validate hash generation inputvalidateColorInput- Validate color conversion inputvalidateQRInput- Validate QR code generation inputvalidateJWTInput- Validate JWT decoding inputvalidatePasswordOptions- Validate password generation options
All responses include standard headers for CORS, caching, and security.
All personal data is fetched from GitHub repositories. Important: Frontend pages fetch from backend API endpoints, NOT directly from GitHub.
- Profile:
https://raw.githubusercontent.com/casjay/public/main/profile.json - Domains:
https://raw.githubusercontent.com/casjay/public/main/domains.json- Structure:
{ "domains": [...], "subDomains": [...] }(note: capital D in subDomains)
- Structure:
- Resume PDF:
https://raw.githubusercontent.com/casjay/public/main/Resume-Tech.pdf - Resume JSON:
https://raw.githubusercontent.com/casjay/public/main/resume.json - Blogs:
https://api.github.com/repos/malaks-us/jason/contents/_posts(196 markdown files) - Git Messages:
https://raw.githubusercontent.com/apimgr/gitmessages/main/src/data/messages.json - Timezones:
https://raw.githubusercontent.com/apimgr/timezones/main/src/data/timezones.json - Countries:
https://raw.githubusercontent.com/apimgr/countries/main/countries.json
JWT-based authentication is required for:
- Todo management endpoints
- Note management endpoints
- URL shortener endpoints
- User profile management
- Register:
POST /api/v1/auth/registerwith username, email, password - Login:
POST /api/v1/auth/loginreturns JWT token - Include token in Authorization header:
Bearer <token> - Tokens expire after 24 hours
- Refresh token:
POST /api/v1/auth/refresh
Rate limiting is applied to prevent abuse:
- Authentication endpoints: 5 requests per minute
- Data creation endpoints: 20 requests per minute
- General endpoints: 100 requests per minute
400- Bad Request (invalid input)401- Unauthorized (missing/invalid auth)403- Forbidden (insufficient permissions)404- Not Found429- Too Many Requests (rate limit)500- Internal Server Error503- Service Unavailable (external service down)
npm install
npm run devSee .env.sample for complete list. Key variables:
PORT- Server port (default: 2000)HOSTNAME- Server hostname (default: localhost)VERSION- API version (default: 1.9.4)TIMEZONE- Server timezone (default: America/New_York)MONGODB_URI- MongoDB connection string (optional)JWT_SECRET- JWT signing secret (required for auth features)NODE_ENV- Environment (development/production)GITHUB_API_KEY- GitHub token for API access (optional but recommended)REDDIT_CLIENT_ID- Reddit client ID (optional)REDDIT_CLIENT_SECRET- Reddit client secret (optional)PROFILE_URL- Profile JSON URL (default: GitHub raw)BLOG_URL- Blog posts URL (default: malaks-us/jason/_posts)DOMAIN_LIST- Domains JSON URL (default: GitHub raw)GIT_MESSAGE_URL- Commit messages JSON URLTIMEZONE_URL- Timezones JSON URLCOUNTRIES_URL- Countries JSON URL
api/
├── api/
│ ├── index.js # Main server file
│ ├── routes/ # All route handlers
│ ├── controllers/ # Business logic
│ ├── models/ # MongoDB models
│ ├── middleware/ # Custom middleware
│ ├── utils/ # Utility functions
│ ├── views/ # EJS templates
│ │ ├── layouts/ # Layout templates
│ │ ├── pages/ # Page templates
│ │ └── partials/ # Reusable components
│ └── public/ # Static assets
│ ├── css/ # Stylesheets
│ ├── js/ # Client-side JavaScript
│ └── images/ # Images
├── package.json
├── now.json # Vercel configuration
└── SPEC.md # This specification
casjay.coffee/ # Separate Vue.js frontend
├── src/
├── dist/
└── package.json
npm test
npm run test:endpoints- Vercel:
vercel deploy - Docker:
docker-compose up
The project uses Vercel for deployment with the following configuration:
- Builder:
@vercel/node(updated from deprecated@now/node) - Configuration file:
now.json(do NOT use bothnow.jsonandvercel.json) - Output directory:
api - MongoDB connection handled via environment variables
- Automatic SSL/HTTPS
- Recent deployment:
https://api-ozmpeipy0-casjaysdev.vercel.app
- Input Validation: All user inputs are validated using dedicated validation functions
- SQL Injection Prevention: Using parameterized queries with MongoDB
- XSS Prevention: Input sanitization and output encoding
- CORS: Configured for specific origins
- Rate Limiting: Applied on sensitive endpoints
- JWT Security: Tokens expire after 24 hours
- Password Security: Passwords hashed using bcrypt (10 rounds)
- HTTPS: Enforced in production via Vercel
- Headers: Security headers set via middleware
- Environment Variables: Sensitive data stored in environment variables
All routes use function-based validation middleware:
router.post('/endpoint', validateInput, async (req, res) => {
// Handler logic
});All endpoints support both JSON and text responses:
// JSON endpoint
router.get('/data', async (req, res) => {
sendJSON(res, formatSuccess(data));
});
// Text endpoint
router.get('/data/text', async (req, res) => {
sendText(res, formatDataAsText(data));
});Consistent error handling across all endpoints:
try {
// Logic
} catch (error) {
sendJSON(res, formatError(error.message), 500);
}-
Server Terminology:
- Changed "System" to "Server" throughout (we are a server, not a system/OS)
- Changed "Hostname" to "FQDN" (Fully Qualified Domain Name)
- Updated version page, API responses, and documentation
-
Dark/Light Theme Toggle:
- Added theme toggle button in navbar (moon/sun icon)
- Persists preference in localStorage
- Respects system
prefers-color-schemepreference - Light theme CSS variables for all components
- No flash of wrong theme on page load
-
API Root Endpoint:
/apinow returns comprehensive help with all available routes- Routes organized by category: Tools, Me, Data, Fun, Social, World, Auth, Server
- Fixed route ordering so
/apiworks before mainRoute catch-all
-
Health Endpoint:
- Health endpoint always returns HTTP 200
- Health status (healthy/degraded) returned in response body
- Allows monitoring tools to parse status from body
-
Blog Posts Frontend:
/data/blogs/:slugnow renders blog posts as HTML pages- Markdown converted to HTML using
markedlibrary - "Read Post" links to frontend instead of GitHub
- API endpoint
/api/v1/data/blogs/post/:slugreturnscontentHtml - Full blog post view with breadcrumbs, metadata, and styling
-
Global JavaScript Utilities:
- Created
utils.jswith type-safe helper functions - Loaded globally on all pages via main layout
- Fixes common JavaScript errors like "text.replace is not a function"
- Provides consistent clipboard, type checking, and HTML escaping utilities
- Documented in
/api/public/js/README.md
- Created
-
Fixed Broken External Data URLs:
- Updated Git Messages URL:
gitmessages/main/src/data/messages.json(repo renamed from Commitmessages) - Fixed Timezone URL: Removed invalid
refs/heads/mainpath segment - Fixed Countries URL: Updated to use correct raw.githubusercontent.com format
- Important: Always use
raw.githubusercontent.comformat, NOTgithub.com/repo/raw
- Updated Git Messages URL:
-
Vercel Deployment Fixes:
- Fixed "Cannot find module 'dotenv'" error
- Updated
now.jsonto use@vercel/nodebuilder instead of deprecated@now/node - Removed conflicting
vercel.jsonfile (cannot use both now.json and vercel.json) - Successfully deployed to production
-
Domains Frontend Enhancement:
- Updated domain controller to properly read
domainsandsubDomainskeys from JSON source - Fixed template to handle both
subDomains(capital D) andsubdomainsnaming conventions - Implemented separate card sections for domains and subdomains on frontend
- Added visual copy feedback: green highlight, checkmark, and "✓ Copied!" message
- Filter out empty subdomain entries from display
- Removed conflicting route handler (mainRoute.js already handles /data/domains)
- Updated domain controller to properly read
-
Frontend Architecture Clarification:
- Frontend pages (
/data/*) fetch data from backend API endpoints - Backend API endpoints fetch from external sources (GitHub, etc.)
- Frontend NEVER fetches directly from GitHub or external sources
- Example flow:
/data/domains→/api/v1/me/info/domains→ GitHub raw URL
- Frontend pages (
-
Route Reorganization (Previous):
- Moved all utility endpoints from
/utilitiesto/tools - Created proper categories (tools, data, fun, social, world)
- Implemented
/me/infofor personal data
- Moved all utility endpoints from
-
Frontend Implementation (Previous):
- Created EJS views for all endpoints
- Implemented consistent theming with Bootstrap 5
- Added interactive forms for all tools
- Updated JavaScript to use new API routes
-
Backward Compatibility (Previous):
- Maintained
/api/v1/gitroutes for casjay.coffee - Legacy
/utilitiesroutes proxy to new/toolsendpoints
- Maintained
-
Resume Enhancement (Previous):
- Added JSON resume endpoint fetching from GitHub
- Text format endpoint for resume
- PDF view/download remain unchanged
This API follows semantic versioning. The current version is v1. Breaking changes will result in a new version (v2).
- GitHub Issues: https://github.com/now-sh/api/issues
- Documentation: https://docs.casjay.coffee
- Contact: casjay@yahoo.com
This project is licensed under the MIT License.