HTTP server work
This commit is contained in:
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"
|
||||
|
||||
|
||||
@@ -7,13 +7,16 @@ export const ExpressLive = Layer.sync(Express, () => express())
|
||||
|
||||
|
||||
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(
|
||||
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