diff --git a/.vscode/settings.json b/.vscode/settings.json index 0c49f65fc..474547a32 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { + "workbench.editor.labelFormat": "short", "explorer.sortOrderLexicographicOptions": "upper", "typescript.preferences.includePackageJsonAutoImports": "on", "typescript.preferences.autoImportFileExcludePatterns": [ diff --git a/api/src/Users.controllers.ts b/api/src/Accounts.ts similarity index 51% rename from api/src/Users.controllers.ts rename to api/src/Accounts.ts index 20d5b6860..1567e9fd0 100644 --- a/api/src/Users.controllers.ts +++ b/api/src/Accounts.ts @@ -1,17 +1,18 @@ import { matchFor } from "api/lib/routing.js" -import { Q, UserRepo } from "api/services.js" -import { Array } from "effect" -import { Effect, Order } from "effect-app" -import { UsersRsc } from "resources.js" -import type { UserView } from "resources/views.js" +import { Array, Effect, Order } from "effect-app" +import { AccountsApi } from "resources.js" +import { UserRepo } from "./Accounts/UserRepo.js" +import type { UserView } from "./Accounts/UserView.js" +import { Q } from "./services.js" -export default matchFor(UsersRsc)([ +export default matchFor(AccountsApi)([ UserRepo.Default -], ({ IndexUsers }) => +], ({ GetMe, Index }) => Effect.gen(function*() { const userRepo = yield* UserRepo return { - IndexUsers: IndexUsers((req) => + GetMe: GetMe(userRepo.getCurrentUser), + Index: Index((req) => userRepo .query(Q.where("id", "in", req.filterByIds)) .pipe(Effect.andThen((users) => ({ diff --git a/api/src/Accounts/Api.ts b/api/src/Accounts/Api.ts new file mode 100644 index 000000000..2caf45b46 --- /dev/null +++ b/api/src/Accounts/Api.ts @@ -0,0 +1,20 @@ +import { User, UserId } from "Domain/User.js" +import { NotFoundError } from "effect-app/client" +import { S } from "lib/resources.js" +import { UserView } from "./UserView.js" + +export class GetMe extends S.Req()("GetMe", {}, { success: User, failure: NotFoundError }) {} + +export class Index extends S.Req()("Index", { + filterByIds: S.NonEmptyArray(UserId) +}, { + allowAnonymous: true, + allowRoles: ["user"], + success: S.Struct({ + users: S.Array(UserView) + }) +}) {} + +//// codegen:start {preset: meta, sourcePrefix: src/User/} +export const meta = { moduleName: "Me" } as const +// codegen:end diff --git a/api/src/services/DBContext/UserRepo.ts b/api/src/Accounts/UserRepo.ts similarity index 95% rename from api/src/services/DBContext/UserRepo.ts rename to api/src/Accounts/UserRepo.ts index 942584331..110e76dbe 100644 --- a/api/src/services/DBContext/UserRepo.ts +++ b/api/src/Accounts/UserRepo.ts @@ -2,15 +2,14 @@ import { Model } from "@effect-app/infra" import { NotFoundError, NotLoggedInError } from "@effect-app/infra/errors" import { generate } from "@effect-app/infra/test" import { RepoConfig } from "api/config.js" +import type { UserId } from "Domain/User.js" +import { User } from "Domain/User.js" import { RepoDefault } from "api/lib/layers.js" +import { Q, UserProfile } from "api/services.js" import { Array, Effect, Exit, Layer, Option, pipe, Request, RequestResolver, S } from "effect-app" import { fakerArb } from "effect-app/faker" import { Email } from "effect-app/Schema" import fc from "fast-check" -import type { UserId } from "models/User.js" -import { User } from "models/User.js" -import { Q } from "../lib.js" -import { UserProfile } from "../UserProfile.js" export type UserSeed = "sample" | "" diff --git a/api/src/resources/resolvers/UserResolver.ts b/api/src/Accounts/UserResolver.ts similarity index 87% rename from api/src/resources/resolvers/UserResolver.ts rename to api/src/Accounts/UserResolver.ts index f40c38b8d..49e3887a7 100644 --- a/api/src/resources/resolvers/UserResolver.ts +++ b/api/src/Accounts/UserResolver.ts @@ -1,12 +1,12 @@ +import { UserId } from "Domain/User.js" import { Effect, Exit, Request, RequestResolver } from "effect" import { Array, Option, pipe, S } from "effect-app" import { ApiConfig, NotFoundError } from "effect-app/client" import { HttpClient } from "effect-app/http" import { type Schema } from "effect-app/Schema" -import { UserId } from "models/User.js" -import { clientFor } from "resources/lib.js" -import * as UsersRsc from "../Users.js" -import { UserView } from "../views/UserView.js" +import { clientFor } from "lib/resources.js" +import { Index } from "./Api.js" +import { UserView } from "./UserView.js" interface GetUserViewById extends Request.Request> { readonly _tag: "GetUserViewById" @@ -14,12 +14,12 @@ interface GetUserViewById extends Request.Request("GetUserViewById") -const userClient = clientFor(UsersRsc) +const usersApi = clientFor({ Index }) const getUserViewByIdResolver = RequestResolver .makeBatched((requests: GetUserViewById[]) => - userClient - .IndexUsers + usersApi + .Index .handler({ filterByIds: pipe(requests.map((_) => _.id), Array.toNonEmptyArray, Option.getOrUndefined)! }) .pipe( Effect.andThen(({ users }) => diff --git a/api/src/resources/views/UserView.ts b/api/src/Accounts/UserView.ts similarity index 82% rename from api/src/resources/views/UserView.ts rename to api/src/Accounts/UserView.ts index 3e6d16cf5..ae0eddd9f 100644 --- a/api/src/resources/views/UserView.ts +++ b/api/src/Accounts/UserView.ts @@ -1,5 +1,5 @@ -import { User } from "models/User.js" -import { S } from "resources/lib.js" +import { User } from "Domain/User.js" +import { S } from "lib/resources.js" export class UserView extends S.ExtendedClass()({ ...User.pick("id", "role"), diff --git a/api/src/Blog.controllers.ts b/api/src/Blog.ts similarity index 84% rename from api/src/Blog.controllers.ts rename to api/src/Blog.ts index 57ac255ed..c9390a35f 100644 --- a/api/src/Blog.controllers.ts +++ b/api/src/Blog.ts @@ -1,19 +1,21 @@ +import { OperationsDefault } from "api/lib/layers.js" import { matchFor } from "api/lib/routing.js" -import { BlogPostRepo, Events, Operations, UserRepo } from "api/services.js" +import { Events, Operations } from "api/services.js" import { Duration, Effect, Schedule } from "effect" import { Option } from "effect-app" import { NonEmptyString2k, NonNegativeInt } from "effect-app/Schema" -import { BlogPost } from "models/Blog.js" -import { BlogRsc } from "resources.js" -import { BogusEvent } from "resources/Events.js" -import { OperationsDefault } from "./lib/layers.js" +import { BlogApi } from "resources.js" +import { UserRepo } from "./Accounts/UserRepo.js" +import { BlogPostRepo } from "./Blog/BlogPostRepo.js" +import { BlogPost } from "./Domain/Blog.js" +import { BogusEvent } from "./Domain/Events.js" -export default matchFor(BlogRsc)([ +export default matchFor(BlogApi)([ BlogPostRepo.Default, UserRepo.Default, OperationsDefault, Events.Default -], ({ CreatePost, FindPost, GetPosts, PublishPost }) => +], ({ CreatePost, FindPost, Index, PublishPost }) => Effect.gen(function*() { const blogPostRepo = yield* BlogPostRepo const userRepo = yield* UserRepo @@ -27,7 +29,7 @@ export default matchFor(BlogRsc)([ .pipe(Effect.andThen(Option.getOrNull)) ), - GetPosts: GetPosts( + Index: Index( blogPostRepo .all .pipe(Effect.andThen((items) => ({ items }))) diff --git a/api/src/resources/Blog.ts b/api/src/Blog/Api.ts similarity index 78% rename from api/src/resources/Blog.ts rename to api/src/Blog/Api.ts index 01078c2d7..14f869929 100644 --- a/api/src/resources/Blog.ts +++ b/api/src/Blog/Api.ts @@ -1,8 +1,8 @@ +import { BlogPost, BlogPostId } from "Domain/Blog.js" +import { S } from "lib/resources.js" import { InvalidStateError, NotFoundError, OptimisticConcurrencyException } from "effect-app/client" import { OperationId } from "effect-app/Operations" -import { BlogPost, BlogPostId } from "models/Blog.js" -import { S } from "./lib.js" -import { BlogPostView } from "./views.js" +import { BlogPostView } from "./PostView.js" export class CreatePost extends S.Req()("CreatePost", BlogPost.pick("title", "body"), { allowRoles: ["user"], @@ -14,7 +14,7 @@ export class FindPost extends S.Req()("FindPost", { id: BlogPostId }, { allowAnonymous: true, allowRoles: ["user"], success: S.NullOr(BlogPostView) }) {} -export class GetPosts extends S.Req()("GetPosts", {}, { +export class Index extends S.Req()("Index", {}, { allowAnonymous: true, allowRoles: ["user"], success: S.Struct({ @@ -26,6 +26,6 @@ export class PublishPost extends S.Req()("PublishPost", { id: BlogPostId }, { allowRoles: ["user"], success: OperationId, failure: S.Union(NotFoundError) }) {} -// codegen:start {preset: meta, sourcePrefix: src/resources/} +//// codegen:start {preset: meta, sourcePrefix: src/Blog/} export const meta = { moduleName: "Blog" } as const // codegen:end diff --git a/api/src/services/DBContext/BlogPostRepo.ts b/api/src/Blog/BlogPostRepo.ts similarity index 90% rename from api/src/services/DBContext/BlogPostRepo.ts rename to api/src/Blog/BlogPostRepo.ts index 33a76d384..214082897 100644 --- a/api/src/services/DBContext/BlogPostRepo.ts +++ b/api/src/Blog/BlogPostRepo.ts @@ -1,11 +1,11 @@ import { Model } from "@effect-app/infra" +import { UserRepo } from "api/Accounts/UserRepo.js" +import { BlogPost } from "Domain/Blog.js" +import { UserFromIdResolver } from "Domain/User.js" import { RepoDefault } from "api/lib/layers.js" import { Effect } from "effect" import { Context } from "effect-app" import { NonEmptyString255, NonEmptyString2k } from "effect-app/Schema" -import { BlogPost } from "models/Blog.js" -import { UserFromIdResolver } from "models/User.js" -import { UserRepo } from "./UserRepo.js" export type BlogPostSeed = "sample" | "" diff --git a/api/src/resources/views/PostView.ts b/api/src/Blog/PostView.ts similarity index 74% rename from api/src/resources/views/PostView.ts rename to api/src/Blog/PostView.ts index c313a0be5..d1fdb857e 100644 --- a/api/src/resources/views/PostView.ts +++ b/api/src/Blog/PostView.ts @@ -1,6 +1,6 @@ -import { BlogPost } from "models/Blog.js" -import { S } from "resources/lib.js" -import { UserViewFromId } from "../resolvers/UserResolver.js" +import { UserViewFromId } from "api/Accounts/UserResolver.js" +import { BlogPost } from "Domain/Blog.js" +import { S } from "lib/resources.js" export class BlogPostView extends S.ExtendedClass()({ ...BlogPost.omit("author"), diff --git a/api/src/models/Blog.ts b/api/src/Domain/Blog.ts similarity index 100% rename from api/src/models/Blog.ts rename to api/src/Domain/Blog.ts diff --git a/api/src/resources/Events.ts b/api/src/Domain/Events.ts similarity index 93% rename from api/src/resources/Events.ts rename to api/src/Domain/Events.ts index 7775dc776..5df964a6a 100644 --- a/api/src/resources/Events.ts +++ b/api/src/Domain/Events.ts @@ -1,5 +1,5 @@ +import { S } from "lib/resources.js" import type { Schema } from "effect-app/Schema" -import { S } from "resources/lib.js" export class BogusEvent extends S.ExtendedTaggedClass()("BogusEvent", { id: S.StringId.withDefault, diff --git a/api/src/models/User.ts b/api/src/Domain/User.ts similarity index 100% rename from api/src/models/User.ts rename to api/src/Domain/User.ts diff --git a/api/src/HelloWorld.controllers.ts b/api/src/HelloWorld.ts similarity index 85% rename from api/src/HelloWorld.controllers.ts rename to api/src/HelloWorld.ts index fdefb1ad8..404388b93 100644 --- a/api/src/HelloWorld.controllers.ts +++ b/api/src/HelloWorld.ts @@ -1,12 +1,12 @@ import { getRequestContext } from "@effect-app/infra/api/setupRequest" import { generate } from "@effect-app/infra/test" import { matchFor } from "api/lib/routing.js" -import { UserRepo } from "api/services.js" import { Effect, S } from "effect-app" -import { User } from "models/User.js" -import { HelloWorldRsc } from "resources.js" +import { HelloWorldApi } from "resources.js" +import { UserRepo } from "./Accounts/UserRepo.js" +import { User } from "./Domain/User.js" -export default matchFor(HelloWorldRsc)([ +export default matchFor(HelloWorldApi)([ UserRepo.Default ], ({ GetHelloWorld }) => Effect.gen(function*() { diff --git a/api/src/resources/HelloWorld.ts b/api/src/HelloWorld/Api.ts similarity index 76% rename from api/src/resources/HelloWorld.ts rename to api/src/HelloWorld/Api.ts index 3f5cb5211..0d5fcd6c2 100644 --- a/api/src/resources/HelloWorld.ts +++ b/api/src/HelloWorld/Api.ts @@ -1,6 +1,6 @@ import { RequestContext } from "@effect-app/infra/RequestContext" -import { S } from "./lib.js" -import { UserView } from "./views.js" +import { UserView } from "api/Accounts/UserView.js" +import { S } from "lib/resources.js" class Response extends S.Class()({ now: S.Date.withDefault, @@ -14,6 +14,6 @@ export class GetHelloWorld extends S.Req()("GetHelloWorld", { echo: S.String }, { allowAnonymous: true, allowRoles: ["user"], success: Response }) {} -// codegen:start {preset: meta, sourcePrefix: src/resources/} +//// codegen:start {preset: meta, sourcePrefix: src/HelloWorld/} export const meta = { moduleName: "HelloWorld" } as const // codegen:end diff --git a/api/src/Me.controllers.ts b/api/src/Me.controllers.ts deleted file mode 100644 index 948e4df11..000000000 --- a/api/src/Me.controllers.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { matchFor } from "api/lib/routing.js" -import { UserRepo } from "api/services.js" -import { Effect } from "effect-app" -import { MeRsc } from "resources.js" - -export default matchFor(MeRsc)([ - UserRepo.Default -], ({ GetMe }) => - Effect.gen(function*() { - const userRepo = yield* UserRepo - return { - GetMe: GetMe(userRepo.getCurrentUser) - } - })) diff --git a/api/src/Operations.controllers.ts b/api/src/Operations.ts similarity index 75% rename from api/src/Operations.controllers.ts rename to api/src/Operations.ts index 11e54b94a..b8c717426 100644 --- a/api/src/Operations.controllers.ts +++ b/api/src/Operations.ts @@ -1,10 +1,10 @@ +import { OperationsDefault } from "api/lib.js" import { matchFor } from "api/lib/routing.js" import { Operations } from "api/services.js" import { Effect } from "effect-app" -import { OperationsRsc } from "resources.js" -import { OperationsDefault } from "./lib/layers.js" +import { OperationsApi } from "resources.js" -export default matchFor(OperationsRsc)([ +export default matchFor(OperationsApi)([ OperationsDefault ], ({ FindOperation }) => Effect.gen(function*() { diff --git a/api/src/resources/Operations.ts b/api/src/Operations/Api.ts similarity index 88% rename from api/src/resources/Operations.ts rename to api/src/Operations/Api.ts index ca301f991..30e60799d 100644 --- a/api/src/resources/Operations.ts +++ b/api/src/Operations/Api.ts @@ -1,19 +1,18 @@ +import { clientFor, S } from "lib/resources.js" import { Duration, Effect } from "effect-app" import { NotFoundError } from "effect-app/client" import { Operation, OperationFailure, OperationId } from "effect-app/Operations" -import { clientFor } from "./lib.js" -import * as S from "./lib/schema.js" export class FindOperation extends S.Req()("FindOperation", { id: OperationId }, { allowAnonymous: true, allowRoles: ["user"], success: S.NullOr(Operation) }) {} -// codegen:start {preset: meta, sourcePrefix: src/resources/} +//// codegen:start {preset: meta, sourcePrefix: src/Operations/} export const meta = { moduleName: "Operations" } as const // codegen:end // Extensions -const opsClient = clientFor({ FindOperation, meta }) +const operationsApi = clientFor({ FindOperation, meta }) export function refreshAndWaitAForOperation( refresh: Effect, @@ -73,13 +72,13 @@ const isFailure = S.is(OperationFailure) function _waitForOperation(id: OperationId, cb?: (op: Operation) => void) { return Effect .gen(function*() { - let r = yield* opsClient.FindOperation.handler({ id }) + let r = yield* operationsApi.FindOperation.handler({ id }) while (r) { if (cb) cb(r) const result = r.result if (result) return isFailure(result) ? yield* Effect.fail(result) : yield* Effect.succeed(result) yield* Effect.sleep(Duration.seconds(2)) - r = yield* opsClient.FindOperation.handler({ id }) + r = yield* operationsApi.FindOperation.handler({ id }) } return yield* new NotFoundError({ type: "Operation", id }) }) diff --git a/api/src/controllers.ts b/api/src/controllers.ts index ca2e26754..b1c7def1e 100644 --- a/api/src/controllers.ts +++ b/api/src/controllers.ts @@ -1,9 +1,8 @@ -// codegen:start {preset: barrel, include: ./*.controllers.ts, import: default} -import blogControllers from "./Blog.controllers.js" -import helloWorldControllers from "./HelloWorld.controllers.js" -import meControllers from "./Me.controllers.js" -import operationsControllers from "./Operations.controllers.js" -import usersControllers from "./Users.controllers.js" +// codegen:start {preset: barrel, include: './[A-Z]*.ts', import: default} +import accounts from "./Accounts.js" +import blog from "./Blog.js" +import helloWorld from "./HelloWorld.js" +import operations from "./Operations.js" -export { blogControllers, helloWorldControllers, meControllers, operationsControllers, usersControllers } +export { accounts, blog, helloWorld, operations } // codegen:end diff --git a/api/src/lib.ts b/api/src/lib.ts new file mode 100644 index 000000000..5ef11cddb --- /dev/null +++ b/api/src/lib.ts @@ -0,0 +1,8 @@ +// codegen:start {preset: barrel, include: ./lib/*.ts, exclude: ./lib/schema.ts} +export * from "./lib/basicRuntime.js" +export * from "./lib/layers.js" +export * from "./lib/middleware.js" +export * from "./lib/observability.js" +export * from "./lib/resources.js" +export * from "./lib/routing.js" +// codegen:end diff --git a/api/src/lib/middleware/events.ts b/api/src/lib/middleware/events.ts index 622dd1842..77c0008cc 100644 --- a/api/src/lib/middleware/events.ts +++ b/api/src/lib/middleware/events.ts @@ -1,6 +1,6 @@ import { makeSSE } from "@effect-app/infra/api/middlewares" +import { ClientEvents } from "Domain/Events.js" import { Events } from "api/services.js" import { Effect } from "effect-app" -import { ClientEvents } from "resources.js" export const makeEvents = Events.pipe(Effect.map((events) => makeSSE(events.stream, ClientEvents))) diff --git a/api/src/lib/resources.ts b/api/src/lib/resources.ts new file mode 100644 index 000000000..a6e6a5ce5 --- /dev/null +++ b/api/src/lib/resources.ts @@ -0,0 +1,2 @@ +export * from "./resources/req.js" +export * as S from "./resources/schema.js" diff --git a/api/src/resources/lib/req.ts b/api/src/lib/resources/req.ts similarity index 86% rename from api/src/resources/lib/req.ts rename to api/src/lib/resources/req.ts index 854a110c4..0e51b07e2 100644 --- a/api/src/resources/lib/req.ts +++ b/api/src/lib/resources/req.ts @@ -1,9 +1,8 @@ import { NotLoggedInError, UnauthorizedError } from "@effect-app/infra/errors" -import { Duration, Layer, Request as EffectRequest } from "effect-app" +import type { Role } from "Domain/User.js" +import { Duration, Layer, Request } from "effect-app" import type { RPCContextMap } from "effect-app/client" import { makeRpcClient } from "effect-app/client" -import type { Role } from "models/User.js" - import { makeClientFor } from "effect-app/client/clientFor" type CTXMap = { @@ -28,9 +27,10 @@ export const { TaggedRequest: Req } = makeRpcClient({ export const RequestCacheLayers = Layer.mergeAll( Layer.setRequestCache( - EffectRequest.makeCache({ capacity: 500, timeToLive: Duration.hours(8) }) + Request.makeCache({ capacity: 500, timeToLive: Duration.hours(8) }) ), Layer.setRequestCaching(true), Layer.setRequestBatching(true) ) + export const clientFor = makeClientFor(RequestCacheLayers) diff --git a/api/src/resources/lib/schema.ts b/api/src/lib/resources/schema.ts similarity index 100% rename from api/src/resources/lib/schema.ts rename to api/src/lib/resources/schema.ts diff --git a/api/src/lib/routing.ts b/api/src/lib/routing.ts index b8a68e127..db000876c 100644 --- a/api/src/lib/routing.ts +++ b/api/src/lib/routing.ts @@ -6,8 +6,8 @@ import { NotLoggedInError, UnauthorizedError } from "@effect-app/infra/errors" import type { RequestContext } from "@effect-app/infra/RequestContext" import { Rpc } from "@effect/rpc" import { BaseConfig } from "api/config.js" -import type { S } from "effect-app" -import { Config, Context, Duration, Effect, Exit, FiberRef, Layer, Option, Request, Schedule } from "effect-app" +import type { Request, S } from "effect-app" +import { Config, Context, Effect, Exit, FiberRef, Layer, Option, Schedule } from "effect-app" import type { GetEffectContext, RPCContextMap } from "effect-app/client" import { HttpHeaders, HttpServerRequest } from "effect-app/http" import type * as EffectRequest from "effect/Request" @@ -17,6 +17,7 @@ import { UserProfile } from "../services/UserProfile.js" import { basicRuntime } from "./basicRuntime.js" +import { RequestCacheLayers } from "./resources/req.js" const optimisticConcurrencySchedule = Schedule.once && Schedule.recurWhile((a) => a?._tag === "OptimisticConcurrencyException") @@ -31,14 +32,6 @@ export type CTXMap = { requireRoles: RPCContextMap.Custom<"", never, typeof UnauthorizedError, Array> } -export const RequestCacheLayers = Layer.mergeAll( - Layer.setRequestCache( - Request.makeCache({ capacity: 500, timeToLive: Duration.hours(8) }) - ), - Layer.setRequestCaching(true), - Layer.setRequestBatching(true) -) - export const Auth0Config = Config.all({ audience: Config.string("audience").pipe(Config.nested("auth0"), Config.withDefault("http://localhost:3610")), issuer: Config.string("issuer").pipe( diff --git a/api/src/resources.ts b/api/src/resources.ts index 5426feae9..ac3eff270 100644 --- a/api/src/resources.ts +++ b/api/src/resources.ts @@ -1,11 +1,10 @@ import type {} from "@effect/platform/HttpClient" -export { ClientEvents } from "./resources/Events.js" +//// codegen:start {preset: barrel, include: './[A-Z]*/Api.ts', import: star} +import * as AccountsApi from "./Accounts/Api.js" +import * as BlogApi from "./Blog/Api.js" +import * as HelloWorldApi from "./HelloWorld/Api.js" +import * as OperationsApi from "./Operations/Api.js" -// codegen:start {preset: barrel, include: ./resources/*.ts, exclude: [./resources/index.ts, ./resources/lib.ts, ./resources/integrationEvents.ts, ./resources/Messages.ts, ./resources/views.ts, ./resources/Events.ts], export: { as: 'PascalCase', postfix: 'Rsc' }} -export * as BlogRsc from "./resources/Blog.js" -export * as HelloWorldRsc from "./resources/HelloWorld.js" -export * as MeRsc from "./resources/Me.js" -export * as OperationsRsc from "./resources/Operations.js" -export * as UsersRsc from "./resources/Users.js" +export { AccountsApi, BlogApi, HelloWorldApi, OperationsApi } // codegen:end diff --git a/api/src/resources/Me.ts b/api/src/resources/Me.ts deleted file mode 100644 index d18c32df4..000000000 --- a/api/src/resources/Me.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NotFoundError } from "effect-app/client" -import { User } from "models/User.js" -import { S } from "./lib.js" - -export class GetMe extends S.Req()("GetMe", {}, { success: User, failure: NotFoundError }) {} - -// codegen:start {preset: meta, sourcePrefix: src/resources/} -export const meta = { moduleName: "Me" } as const -// codegen:end diff --git a/api/src/resources/Users.ts b/api/src/resources/Users.ts deleted file mode 100644 index 024a2e813..000000000 --- a/api/src/resources/Users.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { UserId } from "models/User.js" -import { S } from "./lib.js" -import { UserView } from "./views/UserView.js" - -export class IndexUsers extends S.Req()("IndexUsers", { - filterByIds: S.NonEmptyArray(UserId) -}, { - allowAnonymous: true, - allowRoles: ["user"], - success: S.Struct({ - users: S.Array(UserView) - }) -}) {} - -// codegen:start {preset: meta, sourcePrefix: src/resources/} -export const meta = { moduleName: "Users" } as const -// codegen:end diff --git a/api/src/resources/lib.ts b/api/src/resources/lib.ts deleted file mode 100644 index 61d4ddce7..000000000 --- a/api/src/resources/lib.ts +++ /dev/null @@ -1,5 +0,0 @@ -// codegen:start {preset: barrel, include: ./lib/*.ts, exclude: ./lib/schema.ts} -export * from "./lib/req.js" -// codegen:end - -export * as S from "./lib/schema.js" diff --git a/api/src/resources/views.ts b/api/src/resources/views.ts deleted file mode 100644 index b09859be2..000000000 --- a/api/src/resources/views.ts +++ /dev/null @@ -1,4 +0,0 @@ -// codegen:start {preset: barrel, include: ./views/*.ts} -export * from "./views/PostView.js" -export * from "./views/UserView.js" -// codegen:end diff --git a/api/src/services.ts b/api/src/services.ts index eb74b1bc2..692fe6fb7 100644 --- a/api/src/services.ts +++ b/api/src/services.ts @@ -1,5 +1,4 @@ // codegen:start {preset: barrel, include: services/*.ts } -export * from "./services/DBContext.js" export * from "./services/Events.js" export * from "./services/lib.js" export * from "./services/UserProfile.js" diff --git a/api/src/services/DBContext.ts b/api/src/services/DBContext.ts deleted file mode 100644 index f3dec88d7..000000000 --- a/api/src/services/DBContext.ts +++ /dev/null @@ -1,4 +0,0 @@ -// codegen:start {preset: barrel, include: ./DBContext/* } -export * from "./DBContext/BlogPostRepo.js" -export * from "./DBContext/UserRepo.js" -// codegen:end diff --git a/api/src/services/Events.ts b/api/src/services/Events.ts index 6b19154fb..a9f3a4e16 100644 --- a/api/src/services/Events.ts +++ b/api/src/services/Events.ts @@ -1,7 +1,7 @@ import { storeId } from "@effect-app/infra/Store/Memory" +import type { ClientEvents } from "Domain/Events.js" import { Effect, FiberRef, PubSub, Stream } from "effect-app" import type { NonEmptyReadonlyArray } from "effect/Array" -import type { ClientEvents } from "resources.js" export class Events extends Effect.Service()("Events", { accessors: true, diff --git a/api/src/services/UserProfile.ts b/api/src/services/UserProfile.ts index bcf26a9e2..36cd9c4de 100644 --- a/api/src/services/UserProfile.ts +++ b/api/src/services/UserProfile.ts @@ -1,7 +1,7 @@ import { parseJwt } from "@effect-app/infra/api/routing/schema/jwt" +import { Role } from "Domain/User.js" import { Context, S } from "effect-app" import { UserProfileId } from "effect-app/ids" -import { Role } from "models/User.js" export class UserProfile extends Context.assignTag()( S.Class()({ diff --git a/api/tsconfig.json b/api/tsconfig.json index 317be50d1..792c6a7d9 100644 --- a/api/tsconfig.json +++ b/api/tsconfig.json @@ -1,20 +1,17 @@ { "compilerOptions": { "paths": { - "core/*": [ - "./src/core/*" + "lib/resources.js": [ + "./src/lib/resources.js" ], "resources.js": [ "./src/resources.js" ], - "models.js": [ - "./src/models.js" + "Domain.js": [ + "./src/Domain.js" ], - "resources/*": [ - "./src/resources/*" - ], - "models/*": [ - "./src/models/*" + "Domain/*": [ + "./src/Domain/*" ], "api/*": [ "./src/*" diff --git a/api/tsconfig.src.json b/api/tsconfig.src.json index c12a5fd7c..0736356b6 100644 --- a/api/tsconfig.src.json +++ b/api/tsconfig.src.json @@ -11,20 +11,17 @@ // keep in here, cause madge can't detect it from extended tsconfig "moduleResolution": "Node16", "paths": { - "core/*": [ - "./src/core/*" + "lib/resources.js": [ + "./src/lib/resources.js" ], "resources.js": [ "./src/resources.js" ], - "models.js": [ - "./src/models.js" + "Domain.js": [ + "./src/Domain.js" ], - "resources/*": [ - "./src/resources/*" - ], - "models/*": [ - "./src/models/*" + "Domain/*": [ + "./src/Domain/*" ], "api/*": [ "./src/*" diff --git a/frontend/layouts/default.vue b/frontend/layouts/default.vue index 4de8151cc..5d439bacb 100644 --- a/frontend/layouts/default.vue +++ b/frontend/layouts/default.vue @@ -1,12 +1,12 @@