This commit is contained in:
Julien Valverdé
2024-07-12 03:10:56 +02:00
parent 2fcf809311
commit 574f0b28a6
2 changed files with 36 additions and 38 deletions

View File

@@ -1,7 +1,7 @@
import { BunRuntime } from "@effect/platform-bun"
import { Effect, Layer } from "effect"
import { Todo } from "@todo-tests/common/data"
import { Effect, Layer, Option } from "effect"
import { Services } from "./Services"
import { createDefaultTodos } from "./todo/TodoRepository"
import { ExpressApp } from "./http/ExpressApp"
import { ExpressHTTPServer } from "./http/ExpressHTTPServer"
import { WebSocketServer } from "./http/WebSocketServer"
@@ -10,6 +10,7 @@ import { RPCRoute } from "./rpc/RPCRoute"
import { RPCRouter } from "./rpc/RPCRouter"
import { RPCWebSocketHandler } from "./rpc/RPCWebSocketHandler"
import { RPCProcedureBuilder } from "./rpc/procedures/RPCProcedureBuilder"
import { TodoRepository } from "./todo/TodoRepository"
import { TRPCBuilder } from "./trpc/TRPCBuilder"
import { TRPCContextCreator } from "./trpc/TRPCContextCreator"
@@ -31,7 +32,39 @@ const ServerDev = Layer.empty.pipe(
const main = Effect.gen(function*() {
yield* createDefaultTodos
const todos = yield* TodoRepository
yield* todos.add(new Todo({
id: Option.none(),
order: 0,
content: "Sort the socks",
due: Option.none(),
completed: false,
createdAt: new Date(),
updatedAt: new Date(),
}))
yield* todos.add(new Todo({
id: Option.none(),
order: 1,
content: "Sort the dog",
due: Option.none(),
completed: false,
createdAt: new Date(),
updatedAt: new Date(),
}))
yield* todos.add(new Todo({
id: Option.none(),
order: 2,
content: "Sort the car",
due: Option.none(),
completed: false,
createdAt: new Date(),
updatedAt: new Date(),
}))
yield* Layer.launch(ServerDev)
})

View File

@@ -101,38 +101,3 @@ const updateTodosOrder = Chunk.map<
export class TodoHasID extends Data.TaggedError("TodoHasID")<{ todo: Todo }> {}
export class TodoHasNoID extends Data.TaggedError("TodoHasNoID")<{ todo: Todo }> {}
export const createDefaultTodos = Effect.gen(function*() {
const todos = yield* TodoRepository
yield* todos.add(new Todo({
id: Option.none(),
order: 0,
content: "Sort the socks",
due: Option.none(),
completed: false,
createdAt: new Date(),
updatedAt: new Date(),
}))
yield* todos.add(new Todo({
id: Option.none(),
order: 1,
content: "Sort the dog",
due: Option.none(),
completed: false,
createdAt: new Date(),
updatedAt: new Date(),
}))
yield* todos.add(new Todo({
id: Option.none(),
order: 2,
content: "Sort the car",
due: Option.none(),
completed: false,
createdAt: new Date(),
updatedAt: new Date(),
}))
})