Skip to content

Commit

Permalink
move disc and bag schema/type defs to shared types package
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleveille committed Nov 6, 2024
1 parent fff5280 commit ecea1f9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 32 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"dependencies": {
"@hono/zod-openapi": "^0.16.4",
"@scalar/hono-api-reference": "^0.5.158",
"discit-types": "^2.1.0",
"hono": "^4.6.9",
"mongoose": "^8.7.3"
}
Expand Down
27 changes: 0 additions & 27 deletions src/helpers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,6 @@ export const BaseSchema = new Schema<TBase>({
}
});

export const discSchema = z.object({
id: z.string(),
name: z.string(),
brand: z.string(),
category: z.string(),
speed: z.string(),
glide: z.string(),
turn: z.string(),
fade: z.string(),
stability: z.string(),
link: z.string().optional(),
pic: z.string().optional(),
name_slug: z.string(),
brand_slug: z.string(),
category_slug: z.string(),
stability_slug: z.string(),
color: z.string().optional(),
background_color: z.string().optional()
});

export const discQuerySchema = z.object({
id: z.string().optional(),
name: z.string().optional(),
Expand All @@ -50,10 +30,3 @@ export const discQuerySchema = z.object({
fade: z.string().optional(),
stability: z.string().optional()
});

export const bagSchema = z.object({
id: z.string(),
name: z.string(),
user_id: z.string(),
discs: z.array(z.string())
});
4 changes: 3 additions & 1 deletion src/routes/bag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { assertRequestIsAuthorized, authHeaderSchema, bagSchema, resMessageSchema } from "@helpers";
import { bagSchema } from "discit-types";

import { assertRequestIsAuthorized, authHeaderSchema, resMessageSchema } from "@helpers";
import { createRoute, type OpenAPIHono, z } from "@hono/zod-openapi";
import { Bag } from "@models";

Expand Down
4 changes: 3 additions & 1 deletion src/routes/disc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { assertRequestIsAuthorized, authHeaderSchema, discQuerySchema, discSchema, resMessageSchema } from "@helpers";
import { discSchema } from "discit-types";

import { assertRequestIsAuthorized, authHeaderSchema, discQuerySchema, resMessageSchema } from "@helpers";
import { createRoute, type OpenAPIHono, z } from "@hono/zod-openapi";
import { Disc } from "@models";

Expand Down
8 changes: 5 additions & 3 deletions src/types/abstract/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { bagSchema, discQuerySchema, discSchema } from "@helpers";
import type * as types from "discit-types";

import { discQuerySchema } from "@helpers";
import { z } from "@hono/zod-openapi";

export type TBase = {
created_at: Date;
updated_at: Date;
};

export type TDisc = z.infer<typeof discSchema>;
export type TDisc = types.TDisc;

export type TDiscQuery = z.infer<typeof discQuerySchema>;

export type TBag = z.infer<typeof bagSchema>;
export type TBag = types.TBag;

0 comments on commit ecea1f9

Please sign in to comment.