1# Hono API App
2
3A simple API built with Hono that returns JSON data, including information about the current project and a list of mock projects with "lightweight" in the title.
4
5## Endpoints
18## How to Use
19
20This API is deployed on Val Town and can be accessed via HTTP requests.
21
22Example response from the root endpoint:
23```json
24{
25 "message": "Hello from Hono API",
26 "status": "success",
27 "timestamp": "2023-07-01T12:34:56.789Z",
57 }
58 ],
59 "note": "This is using mock data with the current project included, as the Val Town API access wasn't working as expected."
60}
61```
63## Development
64
65To modify this API:
661. Edit the `index.ts` file to change the endpoints or response data
672. Add new routes by using the Hono app instance
70## Implementation Notes
71
72Since direct access to the Val Town API was not working as expected, this implementation:
73
741. Extracts information about the current project from the runtime environment
774. Returns all this information in the JSON response
78
79This approach ensures that the API always returns useful data, even without direct access to the Val Town API.
37 {
38 id: "current",
39 name: "lightweight-hono-api", // This project
40 description: "A lightweight Hono API that returns JSON from the root endpoint",
41 author: username
42 },
85
86 return c.json({
87 message: "Hello from Hono API",
88 status: "success",
89 timestamp: new Date().toISOString(),
95 currentProject: currentProject,
96 lightweightProjects: lightweightProjects,
97 note: "This is using mock data with the current project included, as the Val Town API access wasn't working as expected."
98 });
99});
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error
1// This val creates a SQLite dashboard admin panel with a sidebar for table names
2// It uses React for the frontend and the Val Town SQLite API for database operations
3// Now includes functionality to edit rows, using rowid or all columns as identifiers
4// and the ability to add new rows to tables
1import { OpenAPIHono } from 'npm:@hono/zod-openapi'
2import { createRoute } from 'npm:@hono/zod-openapi'
3import { extractResumeData } from '../utils/resumeParser.ts'
4import {
14} from '../schemas/resumeSchemas.ts'
15
16const resumeRouter = new OpenAPIHono()
17
18// Define the parse resume route
63
64// Register the route
65resumeRouter.openapi(parseResumeRoute, async (c) => {
66 try {
67 // Extract request body with validation
111
112// Register the schema route
113resumeRouter.openapi(schemaRoute, (c) => {
114 return c.json({
115 resumeParserRequest: ResumeParserRequestSchema.openapi.toJSON(),
116 parsedResume: ParsedResumeSchema.openapi.toJSON()
117 })
118})
1import { OpenAPIHono } from 'npm:@hono/zod-openapi';
2import { createRoute } from 'npm:@hono/zod-openapi';
3import { z } from 'npm:@hono/zod-openapi';
4
5const healthRouter = new OpenAPIHono();
6
7// Define the health response schema
8const HealthResponseSchema = z.object({
9 status: z.string().openapi({
10 example: 'ok'
11 }),
12 version: z.string().openapi({
13 example: '1.0.0'
14 }),
15 timestamp: z.string().openapi({
16 example: new Date().toISOString()
17 }),
18 service: z.string().openapi({
19 example: 'resume-parser-api'
20 })
21}).openapi('HealthResponse');
22
23// Create the health check route
27 tags: ['System'],
28 summary: 'Health Check',
29 description: 'Health check endpoint to verify API is operational',
30 responses: {
31 200: {
32 description: 'API is operational',
33 content: {
34 'application/json': {
41
42// Register the route
43healthRouter.openapi(healthRoute, (c) => {
44 return c.json({
45 status: 'ok',
46 version: '1.0.0',
47 timestamp: new Date().toISOString(),
48 service: 'resume-parser-api'
49 });
50});
31Refer to [Twitter's search operators](https://socialdata.gitbook.io/docs/twitter-tweets/retrieve-search-results-by-keyword#endpoint-parameters) to fine-tune your query.
32
33### 4. Test API call
34Set `isProd = false` in the code if you are testing, to ensure there are enough tweets to display. <br>
35Toggle it back to `true` when you're ready to run this cron job in production and actuall send notifications.
60
61### NOTE: Usage Limits
62This val uses the SocialData API for Twitter data:
63
64- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error
14
15// Public route without authentication
16app.get("/api/public/:id", async (c) => {
17 const key = `__public/${c.req.param("id")}`;
18 const { blob } = await import("https://esm.town/v/std/blob");
132};
133
134app.get("/api/blobs", checkAuth, async (c) => {
135 const prefix = c.req.query("prefix") || "";
136 const limit = parseInt(c.req.query("limit") || "20", 10);
141});
142
143app.get("/api/blob", checkAuth, async (c) => {
144 const key = c.req.query("key");
145 if (!key) return c.text("Missing key parameter", 400);
149});
150
151app.put("/api/blob", checkAuth, async (c) => {
152 const key = c.req.query("key");
153 if (!key) return c.text("Missing key parameter", 400);
158});
159
160app.delete("/api/blob", checkAuth, async (c) => {
161 const key = c.req.query("key");
162 if (!key) return c.text("Missing key parameter", 400);
166});
167
168app.post("/api/blob", checkAuth, async (c) => {
169 const { file, key } = await c.req.parseBody();
170 if (!file || !key) return c.text("Missing file or key", 400);