@lcas58/esmi-api-types 1.0.13 → 1.0.15

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.
@@ -58,7 +58,7 @@ export const list = async (c) => {
58
58
  },
59
59
  limit,
60
60
  offset,
61
- orderBy: (event, { desc }) => [desc(event.startsAt)],
61
+ orderBy: (event, { asc }) => [asc(event.startsAt)],
62
62
  });
63
63
  return c.json(events, HttpStatusCodes.OK);
64
64
  };
@@ -0,0 +1,3 @@
1
+ import type { AppRouteHandler } from "../../lib/types.js";
2
+ import type { MeRoute } from "./users.routes.js";
3
+ export declare const me: AppRouteHandler<MeRoute>;
@@ -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,6 @@
1
+ import { createRouter } from "../../lib/create-app.js";
2
+ import * as handlers from "./users.handlers.js";
3
+ import * as routes from "./users.routes.js";
4
+ const router = createRouter()
5
+ .openapi(routes.me, handlers.me);
6
+ 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
+ });
@@ -2,5 +2,6 @@ import type events from "../routes/events/events.index.js";
2
2
  import type index from "../routes/index.route.js";
3
3
  import type marketing from "../routes/marketing/marketing.index.js";
4
4
  import type sports from "../routes/sports/sports.index.js";
5
+ import type users from "../routes/users/users.index.js";
5
6
  import type webhooks from "../routes/webhooks/webhooks.index.js";
6
- export type AppType = typeof index | typeof events | typeof sports | typeof marketing | typeof webhooks;
7
+ export type AppType = typeof index | typeof events | typeof sports | typeof users | typeof marketing | typeof webhooks;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcas58/esmi-api-types",
3
3
  "type": "module",
4
- "version": "1.0.13",
4
+ "version": "1.0.15",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {