Init backend, frontend and DB schema
This commit is contained in:
29
packages/backend/src/app.ts
Normal file
29
packages/backend/src/app.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Effect } from "effect";
|
||||
import { Request } from "./services/request";
|
||||
import { Storage } from "./services/storage";
|
||||
|
||||
const match = (method: string, ...pattern: readonly string[]) => Effect.gen(function* () {
|
||||
|
||||
const req = yield* Request;
|
||||
|
||||
return req.method === method
|
||||
&& req.path.length === pattern.length
|
||||
&& pattern.every((x, i) => x === "*" || x === req.path[i]);
|
||||
});
|
||||
|
||||
export const app = Effect.gen(function* () {
|
||||
|
||||
const req = yield* Request;
|
||||
const storage = yield* Storage;
|
||||
|
||||
if (yield* match("GET", "ping")) {
|
||||
return new Response("pong", {
|
||||
headers: {
|
||||
"Content-Length": "4",
|
||||
"Content-Type": "text/plain;charset=utf-8",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return new Response(null, { status: 404 });
|
||||
});
|
||||
Reference in New Issue
Block a user