Ship Novya PWA with backend for deployable production use.
Fix production TypeScript builds and add DEPLOY.md so the app can be hosted from this repo. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { Hono } from 'hono';
|
||||
import { jsonValidator, queryValidator } from '../../shared/validation/index.js';
|
||||
import { created, success } from '../../lib/response.js';
|
||||
import { requireAuth } from '../../middleware/auth.js';
|
||||
import {
|
||||
createChatSessionSchema,
|
||||
listChatSessionsQuerySchema,
|
||||
sendChatMessageSchema,
|
||||
} from './chat.schemas.js';
|
||||
import {
|
||||
createChatSession,
|
||||
listChatMessages,
|
||||
listChatSessions,
|
||||
sendChatMessage,
|
||||
startChatSession,
|
||||
} from './chat.service.js';
|
||||
|
||||
export function createChatRoutes() {
|
||||
const routes = new Hono();
|
||||
|
||||
routes.get('/sessions', requireAuth, queryValidator(listChatSessionsQuerySchema), async (c) => {
|
||||
const authUser = c.get('authUser');
|
||||
const { sessionOrder } = c.req.valid('query');
|
||||
const result = await listChatSessions(authUser.id, sessionOrder);
|
||||
return success(c, result);
|
||||
});
|
||||
|
||||
routes.post('/sessions', requireAuth, jsonValidator(createChatSessionSchema), async (c) => {
|
||||
const authUser = c.get('authUser');
|
||||
const { sessionOrder } = c.req.valid('json');
|
||||
const result = await createChatSession(authUser.id, sessionOrder);
|
||||
return created(c, result);
|
||||
});
|
||||
|
||||
routes.get('/sessions/:id/messages', requireAuth, async (c) => {
|
||||
const authUser = c.get('authUser');
|
||||
const result = await listChatMessages(authUser.id, BigInt(c.req.param('id')));
|
||||
return success(c, result);
|
||||
});
|
||||
|
||||
routes.post(
|
||||
'/sessions/:id/messages',
|
||||
requireAuth,
|
||||
jsonValidator(sendChatMessageSchema),
|
||||
async (c) => {
|
||||
const authUser = c.get('authUser');
|
||||
const { content } = c.req.valid('json');
|
||||
const result = await sendChatMessage(authUser.id, BigInt(c.req.param('id')), content);
|
||||
return created(c, result);
|
||||
},
|
||||
);
|
||||
|
||||
routes.post('/sessions/:id/start', requireAuth, async (c) => {
|
||||
const authUser = c.get('authUser');
|
||||
const result = await startChatSession(authUser.id, BigInt(c.req.param('id')));
|
||||
return success(c, result);
|
||||
});
|
||||
|
||||
return routes;
|
||||
}
|
||||
Reference in New Issue
Block a user