| 1 | import { defineConfig, RenderRoute, ServerRoute } from "@octanejs/vite-plugin"; |
| 2 | |
| 3 | const prefix = "native-config"; |
| 4 | |
| 5 | export default defineConfig({ |
| 6 | build: { outDir: "output", minify: false }, |
| 7 | router: { |
| 8 | routes: [ |
| 9 | new RenderRoute({ path: "/", entry: ["App", "/src/App.tsx"] }), |
| 10 | new RenderRoute({ path: "/other", entry: ["App", "/src/App.tsx"] }), |
| 11 | new ServerRoute({ |
| 12 | path: "/api/hello", |
| 13 | methods: ["GET"], |
| 14 | handler: (context) => { |
| 15 | const platform = context.platform as { |
| 16 | env: { MESSAGE: string }; |
| 17 | ctx: { waitUntil: unknown }; |
| 18 | }; |
| 19 | return Response.json({ |
| 20 | message: `${prefix}:${platform.env.MESSAGE}`, |
| 21 | hasWaitUntil: typeof platform.ctx.waitUntil === "function", |
| 22 | }); |
| 23 | }, |
| 24 | }), |
| 25 | ], |
| 26 | }, |
| 27 | }); |