-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reinstate the usage of any use-any-unit (#474)
- Loading branch information
1 parent
2d3850c
commit beff973
Showing
5 changed files
with
76 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 3 additions & 15 deletions
18
src/server/api/modules/grocy/procedures/getGrocyProducts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
import { grocyFetch } from "~/server/api/modules/grocy/service/client" | ||
import { getGrocyProducts } from "~/server/api/modules/grocy/service/getGrocyProducts" | ||
import { protectedProcedure } from "~/server/api/trpc" | ||
import z from "zod" | ||
|
||
const grocyProductSchema = z.object({ | ||
id: z.coerce.string(), | ||
name: z.string(), | ||
qu_id_stock: z.coerce.string(), | ||
}) | ||
|
||
export const getGrocyProductsProcedure = protectedProcedure.query(async () => { | ||
const prods = await grocyFetch("/objects/products", { cache: "no-cache" }) | ||
|
||
const json = await prods.json() | ||
|
||
return grocyProductSchema.array().parse(json) | ||
}) | ||
export const getGrocyProductsProcedure = | ||
protectedProcedure.query(getGrocyProducts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { grocyFetch } from "~/server/api/modules/grocy/service/client" | ||
import z from "zod" | ||
|
||
const grocyProductSchema = z.object({ | ||
id: z.coerce.string(), | ||
name: z.string(), | ||
qu_id_stock: z.coerce.string(), | ||
}) | ||
|
||
type GrocyProduct = z.infer<typeof grocyProductSchema> | ||
|
||
export const getGrocyProducts = async (): Promise<GrocyProduct[]> => { | ||
const prods = await grocyFetch("/objects/products", { cache: "no-cache" }) | ||
|
||
const json = await prods.json() | ||
|
||
return grocyProductSchema.array().parse(json) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters