my-first-val54
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
https://ahmed33--b73b1004d4d64771b93d46b32b9590f2.web.val.run
A REST API built with Hono that provides job listing management and a public chat room functionality.
- Job Listings API: Post and retrieve job listings
- Public Chat: Real-time chat room for public discussions
- Web Interface: Simple frontend to interact with the API
- SQLite Storage: Persistent data storage using Val Town's SQLite
├── backend/
│ ├── index.ts # Main API server (HTTP endpoint)
│ └── database/
│ ├── migrations.ts # Database schema definitions
│ └── queries.ts # Database query functions
├── frontend/
│ ├── index.html # Web interface
│ └── app.js # Frontend JavaScript
└── README.md
-
POST /api/jobs - Create a new job listing
{ "title": "Software Engineer", "company": "Tech Corp", "description": "We're looking for...", "location": "Remote", // optional "salary": "$80k-120k", // optional "contactEmail": "hr@techcorp.com" } -
GET /api/jobs - Get all job listings
-
GET /api/jobs/:id - Get a specific job by ID
-
POST /api/chat - Post a message to the chat
{ "username": "john_doe", "message": "Hello everyone!" } -
GET /api/chat - Get recent chat messages
- Optional query parameter:
?limit=N(default: 50)
- Optional query parameter:
- GET /api - Get full API documentation with schemas
- Web Interface: Visit the main URL to use the interactive web interface
- API Access: Make HTTP requests to the endpoints listed above
- Testing: Use tools like curl, Postman, or the built-in web interface
curl -X POST /api/jobs \ -H "Content-Type: application/json" \ -d '{ "title": "Frontend Developer", "company": "StartupXYZ", "description": "Looking for a React developer...", "location": "San Francisco", "salary": "$90k-130k", "contactEmail": "jobs@startupxyz.com" }'
curl /api/jobs
curl -X POST /api/chat \ -H "Content-Type: application/json" \ -d '{ "username": "developer123", "message": "Anyone hiring React developers?" }'
curl /api/chat?limit=20
id- Auto-incrementing primary keytitle- Job title (required)company- Company name (required)description- Job description (required)location- Job location (optional)salary- Salary information (optional)contact_email- Contact email (required)created_at- Timestampupdated_at- Timestamp
id- Auto-incrementing primary keyusername- Username (required, max 50 chars)message- Message content (required, max 500 chars)created_at- Timestamp
The API is built using:
- Hono - Fast web framework
- SQLite - Database storage
- TypeScript - Type safety
- Val Town Utils - File serving utilities
The API returns appropriate HTTP status codes:
200- Success201- Created400- Bad Request (validation errors)404- Not Found500- Internal Server Error
Cron
Email