mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
feat(api): add elysia server for cloudflare workers
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@opencut/api",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev": "wrangler dev",
|
||||
"deploy": "wrangler deploy",
|
||||
"build": "wrangler deploy --dry-run"
|
||||
},
|
||||
"dependencies": {
|
||||
"elysia": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "latest",
|
||||
"wrangler": "latest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Elysia, t } from "elysia";
|
||||
import { CloudflareAdapter } from "elysia/adapter/cloudflare-worker";
|
||||
|
||||
export default new Elysia({ adapter: CloudflareAdapter })
|
||||
.get("/", () => ({ status: "ok" }))
|
||||
.get("/health", () => ({ healthy: true, timestamp: new Date().toISOString() }))
|
||||
.post(
|
||||
"/echo",
|
||||
({ body }) => body,
|
||||
{
|
||||
body: t.Object({ message: t.String() }),
|
||||
}
|
||||
)
|
||||
// .compile() is required — it triggers AoT compilation at startup
|
||||
.compile();
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "node_modules/wrangler/config-schema.json",
|
||||
"name": "opencut-api",
|
||||
"main": "src/index.ts",
|
||||
// Minimum date required for CloudflareAdapter AoT support
|
||||
"compatibility_date": "2025-06-01"
|
||||
}
|
||||
Reference in New Issue
Block a user