@lcas58/esmi-api-types 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/routes/events/events.handlers.js +1 -1
- package/dist/src/routes/users/users.handlers.d.ts +3 -0
- package/dist/src/routes/users/users.handlers.js +33 -0
- package/dist/src/routes/users/users.index.d.ts +31 -0
- package/dist/src/routes/users/users.index.js +6 -0
- package/dist/src/routes/users/users.routes.d.ts +72 -0
- package/dist/src/routes/users/users.routes.js +27 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
3
|
+
import * as HttpStatusPhrases from "stoker/http-status-phrases";
|
|
4
|
+
import { createDb } from "../../db/index.js";
|
|
5
|
+
import { user } from "../../db/schema/index.js";
|
|
6
|
+
export const me = async (c) => {
|
|
7
|
+
const sessionUser = c.get("user");
|
|
8
|
+
if (!sessionUser) {
|
|
9
|
+
return c.json({ message: HttpStatusPhrases.UNAUTHORIZED }, HttpStatusCodes.UNAUTHORIZED);
|
|
10
|
+
}
|
|
11
|
+
const { db } = createDb(c.env);
|
|
12
|
+
const foundUser = await db.query.user.findFirst({
|
|
13
|
+
where: eq(user.id, sessionUser.id),
|
|
14
|
+
columns: {
|
|
15
|
+
id: true,
|
|
16
|
+
name: true,
|
|
17
|
+
email: true,
|
|
18
|
+
emailVerified: true,
|
|
19
|
+
image: true,
|
|
20
|
+
onboardingStatus: true,
|
|
21
|
+
onboardingVersion: true,
|
|
22
|
+
onboardingCompletedAt: true,
|
|
23
|
+
homeCity: true,
|
|
24
|
+
homeState: true,
|
|
25
|
+
homeCountry: true,
|
|
26
|
+
sports: true,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (!foundUser) {
|
|
30
|
+
return c.json({ message: HttpStatusPhrases.UNAUTHORIZED }, HttpStatusCodes.UNAUTHORIZED);
|
|
31
|
+
}
|
|
32
|
+
return c.json(foundUser, HttpStatusCodes.OK);
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shared/index.js").AppBindings, {
|
|
2
|
+
"/me": {
|
|
3
|
+
$get: {
|
|
4
|
+
input: {};
|
|
5
|
+
output: {
|
|
6
|
+
image: string | null;
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
emailVerified: boolean;
|
|
11
|
+
onboardingStatus: "not_started" | "in_progress" | "completed";
|
|
12
|
+
onboardingVersion: number;
|
|
13
|
+
onboardingCompletedAt: string | null;
|
|
14
|
+
homeCity: string | null;
|
|
15
|
+
homeState: string | null;
|
|
16
|
+
homeCountry: string | null;
|
|
17
|
+
sports: string[] | null;
|
|
18
|
+
};
|
|
19
|
+
outputFormat: "text" | "json";
|
|
20
|
+
status: 200;
|
|
21
|
+
} | {
|
|
22
|
+
input: {};
|
|
23
|
+
output: {
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
outputFormat: "text" | "json";
|
|
27
|
+
status: 401;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}, "/">;
|
|
31
|
+
export default router;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export declare const me: {
|
|
3
|
+
path: "/me";
|
|
4
|
+
method: "get";
|
|
5
|
+
tags: string[];
|
|
6
|
+
responses: {
|
|
7
|
+
200: {
|
|
8
|
+
content: {
|
|
9
|
+
"application/json": {
|
|
10
|
+
schema: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
email: z.ZodString;
|
|
14
|
+
emailVerified: z.ZodBoolean;
|
|
15
|
+
image: z.ZodNullable<z.ZodString>;
|
|
16
|
+
onboardingStatus: z.ZodEnum<["not_started", "in_progress", "completed"]>;
|
|
17
|
+
onboardingVersion: z.ZodNumber;
|
|
18
|
+
onboardingCompletedAt: z.ZodNullable<z.ZodDate>;
|
|
19
|
+
homeCity: z.ZodNullable<z.ZodString>;
|
|
20
|
+
homeState: z.ZodNullable<z.ZodString>;
|
|
21
|
+
homeCountry: z.ZodNullable<z.ZodString>;
|
|
22
|
+
sports: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
image: string | null;
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
email: string;
|
|
28
|
+
emailVerified: boolean;
|
|
29
|
+
onboardingStatus: "not_started" | "in_progress" | "completed";
|
|
30
|
+
onboardingVersion: number;
|
|
31
|
+
onboardingCompletedAt: Date | null;
|
|
32
|
+
homeCity: string | null;
|
|
33
|
+
homeState: string | null;
|
|
34
|
+
homeCountry: string | null;
|
|
35
|
+
sports: string[] | null;
|
|
36
|
+
}, {
|
|
37
|
+
image: string | null;
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
email: string;
|
|
41
|
+
emailVerified: boolean;
|
|
42
|
+
onboardingStatus: "not_started" | "in_progress" | "completed";
|
|
43
|
+
onboardingVersion: number;
|
|
44
|
+
onboardingCompletedAt: Date | null;
|
|
45
|
+
homeCity: string | null;
|
|
46
|
+
homeState: string | null;
|
|
47
|
+
homeCountry: string | null;
|
|
48
|
+
sports: string[] | null;
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
401: {
|
|
55
|
+
content: {
|
|
56
|
+
"application/json": {
|
|
57
|
+
schema: z.ZodObject<{
|
|
58
|
+
message: z.ZodString;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
message: string;
|
|
61
|
+
}, {
|
|
62
|
+
message: string;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
} & {
|
|
70
|
+
getRoutingPath(): "/me";
|
|
71
|
+
};
|
|
72
|
+
export type MeRoute = typeof me;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
3
|
+
import { jsonContent } from "stoker/openapi/helpers";
|
|
4
|
+
import { unauthorizedSchema } from "../../lib/constants.js";
|
|
5
|
+
const userProfileSchema = z.object({
|
|
6
|
+
id: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
email: z.string(),
|
|
9
|
+
emailVerified: z.boolean(),
|
|
10
|
+
image: z.string().nullable(),
|
|
11
|
+
onboardingStatus: z.enum(["not_started", "in_progress", "completed"]),
|
|
12
|
+
onboardingVersion: z.number(),
|
|
13
|
+
onboardingCompletedAt: z.date().nullable(),
|
|
14
|
+
homeCity: z.string().nullable(),
|
|
15
|
+
homeState: z.string().nullable(),
|
|
16
|
+
homeCountry: z.string().nullable(),
|
|
17
|
+
sports: z.array(z.string()).nullable(),
|
|
18
|
+
});
|
|
19
|
+
export const me = createRoute({
|
|
20
|
+
path: "/me",
|
|
21
|
+
method: "get",
|
|
22
|
+
tags: ["Users"],
|
|
23
|
+
responses: {
|
|
24
|
+
[HttpStatusCodes.OK]: jsonContent(userProfileSchema, "Current user profile"),
|
|
25
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Not authenticated"),
|
|
26
|
+
},
|
|
27
|
+
});
|