import { defineSchema, defineTable } from "convex/schema";
import { v } from "convex/values";
export default defineSchema({
users: defineTable({
name: v.string(),
}),
messages: defineTable({
text: v.string(),
authorName: v.string(),
}),
});
http.route({
path: "/api/hello",
method: "GET",
handler: async (ctx) => {
return new Response("there", {
status: 200,
headers: {
"Content-Type": "text/plain",
},
});
},
});
also creating handler at http.config.ts
??
http.route({
path: "/api/hello",
method: "GET",
handler: hello.handleGet,
});
// Route for /api/messages/*
http.route({
path: "/api/messages/*",
method: "POST",
handler: messages.handlePost,
});
and then pulling out the handler into separate files and hallucinating types.
export const hello = {
handleGet: async (request: Http.Request) => {
// Get the request body as text
const bodyText = await request.text();
// Return the concatenated response
return new Response(bodyText + "there", {
status: 200,
headers: {
"Content-Type": "text/plain",
},
});
},
};