mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
Add support for extra api routes (#3308)
Introduce new server section in Mastra to support server configuration.
```
server: {
// replaces serverMiddlware
middleware: [
async (c, next) => {
console.log("middleware", c.req.url);
await next();
},
],
// collection of routes
apiRoutes: [
registerApiRoute("/cool/stuff", {
method: "GET",
openapi: {
description: "Get API status",
tags: ["system"],
responses: {
200: {
description: "Success",
},
},
},
handler: (c) => {
return c.json({ message: "Hello, world!" });
},
}),
registerApiRoute("/cool/posts/:id", {
method: "GET",
handler: (c) => {
const x = c.get("mastra");
return c.json({ message: "Hello, world!", id: c.req.param("id") });
},
}),
],
},
```
This commit is contained in:
parent
04db7eca1e
commit
304397c5fc
8 changed files with 139 additions and 5 deletions
Loading…
Add table
Add a link
Reference in a new issue