Express work
This commit is contained in:
6
packages/server/src/express/Express.ts
Normal file
6
packages/server/src/express/Express.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { Context, Layer } from "effect"
|
||||||
|
import express from "express"
|
||||||
|
|
||||||
|
|
||||||
|
export class Express extends Context.Tag("Express")<Express, ReturnType<typeof express>>() {}
|
||||||
|
export const ExpressLive = Layer.sync(Express, () => express())
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
import { Config, Context, Effect, Layer } from "effect"
|
import { Config, Effect, Layer } from "effect"
|
||||||
import express from "express"
|
import { Express, ExpressLive } from "./Express"
|
||||||
|
|
||||||
|
|
||||||
export class Express extends Context.Tag("Express")<Express, ReturnType<typeof express>>() {}
|
export const HTTPServerLive = Layer.scopedDiscard(Effect.gen(function*() {
|
||||||
export const ExpressLive = Layer.sync(Express, () => express())
|
|
||||||
|
|
||||||
|
|
||||||
export const ServerLive = Layer.scopedDiscard(Effect.gen(function*() {
|
|
||||||
const app = yield* Express
|
const app = yield* Express
|
||||||
const port = yield* Config.number("PORT").pipe(Config.withDefault(8080))
|
const port = yield* Config.number("PORT").pipe(Config.withDefault(8080))
|
||||||
|
|
||||||
Reference in New Issue
Block a user