Cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Layer } from "effect"
|
||||
import { TodoRepository } from "./TodoRepository"
|
||||
import { TodoRepository } from "./todo/TodoRepository"
|
||||
|
||||
|
||||
type TServices =
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { BunRuntime } from "@effect/platform-bun"
|
||||
import { Todo, type IdentifiedTodo } from "@todo-tests/common/data"
|
||||
import { Identifiable } from "@todo-tests/common/traits"
|
||||
import { Chunk, Effect, Layer, Stream } from "effect"
|
||||
import { Effect, Layer } from "effect"
|
||||
import { Services } from "./Services"
|
||||
import { TodoRepository, createDefaultTodos } from "./TodoRepository"
|
||||
import { createDefaultTodos } from "./todo/TodoRepository"
|
||||
import { ExpressApp } from "./http/ExpressApp"
|
||||
import { ExpressHTTPServer } from "./http/ExpressHTTPServer"
|
||||
import { WebSocketServer } from "./http/WebSocketServer"
|
||||
@@ -32,51 +30,8 @@ const ServerDev = Layer.empty.pipe(
|
||||
)
|
||||
|
||||
|
||||
const watchTodoChanges = Effect.gen(function*() {
|
||||
const todos = yield* TodoRepository
|
||||
// yield* Stream.runForEach(todos.todos.changes, todos => Console.log(`Todos changed: ${ todos }`))
|
||||
yield* todos.todos.changes.pipe(
|
||||
Stream.runFold(
|
||||
Chunk.empty<IdentifiedTodo>(),
|
||||
|
||||
(prev, curr) => {
|
||||
console.log(`Added todos: ${ Chunk.differenceWith<Todo>(Identifiable.equals)(curr, prev) }`)
|
||||
console.log(`Removed todos: ${ Chunk.differenceWith<Todo>(Identifiable.equals)(prev, curr) }`)
|
||||
|
||||
return curr
|
||||
},
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
const main = Effect.gen(function*() {
|
||||
// const watcher = yield* Effect.fork(watchTodoChanges)
|
||||
yield* createDefaultTodos
|
||||
|
||||
// const todos = yield* TodoRepository
|
||||
|
||||
// const secondTodo = yield* yield* todos.todos.get.pipe(
|
||||
// Effect.map(Array.get(1))
|
||||
// )
|
||||
// const secondTodoModified = new Todo({
|
||||
// ...secondTodo,
|
||||
// completed: true,
|
||||
// })
|
||||
// yield* todos.update(secondTodoModified)
|
||||
|
||||
// yield* todos.add(new Todo({
|
||||
// id: Option.none(),
|
||||
// title: "Put the dishes in the dishwasher",
|
||||
// content: "Lorem ipsum",
|
||||
// due: Option.none(),
|
||||
// completed: false,
|
||||
// createdAt: new Date(),
|
||||
// updatedAt: new Date(),
|
||||
// })).pipe(
|
||||
// Effect.delay(Duration.seconds(1))
|
||||
// )
|
||||
|
||||
// yield* Fiber.join(watcher)
|
||||
yield* Layer.launch(ServerDev)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Schema as S } from "@effect/schema"
|
||||
import { JsonifiableTodo } from "@todo-tests/common/data"
|
||||
import { observable } from "@trpc/server/observable"
|
||||
import { Effect, Fiber, Runtime, Stream, flow } from "effect"
|
||||
import { TodoRepository } from "../../TodoRepository"
|
||||
import { TodoRepository } from "../../todo/TodoRepository"
|
||||
import { TRPCBuilder } from "../../trpc/TRPCBuilder"
|
||||
import { RPCProcedureBuilder } from "../procedures/RPCProcedureBuilder"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user