HTTP server work
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
"@effect/schema": "^0.68.12",
|
"@effect/schema": "^0.68.12",
|
||||||
"@thilawyn/thilalib": "^0.1.4",
|
"@thilawyn/thilalib": "^0.1.4",
|
||||||
"@todo-tests/common": "workspace:*",
|
"@todo-tests/common": "workspace:*",
|
||||||
|
"@trpc/server": "^10.45.2",
|
||||||
"effect": "^3.4.5",
|
"effect": "^3.4.5",
|
||||||
"express": "^4.19.2"
|
"express": "^4.19.2"
|
||||||
},
|
},
|
||||||
|
|||||||
0
packages/server/src/api/trpc/index.ts
Normal file
0
packages/server/src/api/trpc/index.ts
Normal file
@@ -1,4 +1,4 @@
|
|||||||
import { Context, Effect, Layer } from "effect"
|
import { Config, Context, Effect, Layer } from "effect"
|
||||||
import express from "express"
|
import express from "express"
|
||||||
|
|
||||||
|
|
||||||
@@ -7,13 +7,16 @@ export const ExpressLive = Layer.sync(Express, () => express())
|
|||||||
|
|
||||||
|
|
||||||
export const ServerLive = Layer.scopedDiscard(Effect.gen(function*() {
|
export const ServerLive = Layer.scopedDiscard(Effect.gen(function*() {
|
||||||
const port = 8080
|
|
||||||
const app = yield* Express
|
const app = yield* Express
|
||||||
|
const port = yield* Config.number("PORT").pipe(Config.withDefault(8080))
|
||||||
|
|
||||||
yield* Effect.acquireRelease(
|
yield* Effect.acquireRelease(
|
||||||
Effect.sync(() =>
|
Effect.sync(() =>
|
||||||
app.listen(port, () => console.log(`Example app listening on port ${ port }`))
|
app.listen(port, () => console.log(`HTTP server listening on ${ port }.`))
|
||||||
|
),
|
||||||
|
|
||||||
|
server => Effect.sync(() =>
|
||||||
|
server.close()
|
||||||
),
|
),
|
||||||
server => Effect.sync(() => server.close()),
|
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
|||||||
0
packages/server/src/trpc.ts
Normal file
0
packages/server/src/trpc.ts
Normal file
Reference in New Issue
Block a user