feat: modular domain driven boilerplate
This commit is contained in:
12
modules/identity/routes/identities/me/handle.ts
Normal file
12
modules/identity/routes/identities/me/handle.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { UnauthorizedError } from "@platform/relay";
|
||||
|
||||
import { getIdentityById } from "../../../database.ts";
|
||||
import route from "./spec.ts";
|
||||
|
||||
export default route.access("session").handle(async ({ principal }) => {
|
||||
const identity = await getIdentityById(principal.id);
|
||||
if (identity === undefined) {
|
||||
return new UnauthorizedError("You must be signed in to view your session.");
|
||||
}
|
||||
return identity;
|
||||
});
|
||||
5
modules/identity/routes/identities/me/spec.ts
Normal file
5
modules/identity/routes/identities/me/spec.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { NotFoundError, route, UnauthorizedError } from "@platform/relay";
|
||||
|
||||
import { IdentitySchema } from "../../../models/identity.ts";
|
||||
|
||||
export default route.get("/api/v1/identities/me").response(IdentitySchema).errors([UnauthorizedError, NotFoundError]);
|
||||
Reference in New Issue
Block a user