-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from icssc/get-menu
Schema updates/menu.get
- Loading branch information
Showing
59 changed files
with
11,592 additions
and
5,026 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": ["config:base"], | ||
"extends": [ | ||
"config:base" | ||
], | ||
"packageRules": [ | ||
{ | ||
"matchPackagePatterns": ["^@acme/"], | ||
"matchPackagePatterns": [ | ||
"^@zotmeal/" | ||
], | ||
"enabled": false | ||
} | ||
], | ||
"updateInternalDeps": true, | ||
"rangeStrategy": "bump", | ||
"automerge": true | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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
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
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,14 +1,26 @@ | ||
{ | ||
"extends": "@acme/tsconfig/base.json", | ||
"extends": "@zotmeal/tsconfig/base.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": ["./src/*"] | ||
"~/*": [ | ||
"./src/*" | ||
] | ||
}, | ||
"jsx": "react-native", | ||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json", | ||
"types": ["nativewind/types"] | ||
"types": [ | ||
"nativewind/types" | ||
] | ||
}, | ||
"include": ["src", "*.ts", "*.js", ".expo/types/**/*.ts", "expo-env.d.ts"], | ||
"exclude": ["node_modules"] | ||
} | ||
"include": [ | ||
"src", | ||
"*.ts", | ||
"*.js", | ||
".expo/types/**/*.ts", | ||
"expo-env.d.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
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 was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
{ | ||
"name": "@acme/api", | ||
"name": "@zotmeal/api", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "echo 'Add dev script here'", | ||
"build": "echo 'Add build script here'", | ||
"test": "echo 'Add test script here'", | ||
"test": "vitest", | ||
"lint": "echo 'Add lint script here'" | ||
}, | ||
"dependencies": { | ||
"@acme/db": "workspace:^", | ||
"@acme/eslint-config": "workspace:^", | ||
"@acme/tsconfig": "workspace:^", | ||
"@acme/validators": "workspace:^", | ||
"@trpc/server": "11.0.0-next-beta.236", | ||
"@zotmeal/db": "workspace:^", | ||
"@zotmeal/eslint-config": "workspace:^", | ||
"@zotmeal/prettier-config": "workspace:^", | ||
"@zotmeal/tsconfig": "workspace:^", | ||
"@zotmeal/utils": "workspace:^", | ||
"@zotmeal/validators": "workspace:^", | ||
"date-fns": "^3.3.1", | ||
"superjson": "2.2.1", | ||
"vitest": "^1.2.2", | ||
"zod": "^3.22.4" | ||
}, | ||
"eslintConfig": { | ||
"root": true, | ||
"extends": [ | ||
"@acme/eslint-config/base" | ||
"@zotmeal/eslint-config/base" | ||
] | ||
}, | ||
"prettier": "@acme/prettier-config" | ||
"prettier": "@zotmeal/prettier-config" | ||
} |
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 was deleted.
Oops, something went wrong.
File renamed without changes.
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,7 @@ | ||
import { describe, it } from "vitest"; | ||
|
||
describe("", () => { | ||
it("", () => { | ||
console.log(""); | ||
}); | ||
}); |
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,61 @@ | ||
import { TRPCError } from "@trpc/server"; | ||
import { parse } from "date-fns"; | ||
import { z } from "zod"; | ||
|
||
import { MenuPeriod, RestaurantName } from "@zotmeal/db"; | ||
|
||
import { publicProcedure } from "../../trpc"; | ||
|
||
export const GetMenuSchema = z.object({ | ||
date: z.string().regex(RegExp("/^d{2}/d{2}/d{4}$/")), | ||
period: z.nativeEnum(MenuPeriod), | ||
restaurant: z.nativeEnum(RestaurantName), | ||
}); | ||
|
||
export const getMenuProcedure = publicProcedure | ||
.input(GetMenuSchema) | ||
.query(async ({ ctx, input }) => { | ||
// get a menu | ||
const { date: dateString, period, restaurant: restaurantName } = input; | ||
const { db } = ctx; | ||
const restaurant = await db.restaurant.findFirst({ | ||
where: { | ||
name: restaurantName, | ||
}, | ||
include: { | ||
stations: false, | ||
menu: false, | ||
}, | ||
}); | ||
|
||
// should 404 | ||
if (restaurant === null) { | ||
throw new TRPCError({ | ||
message: "restaurant not found", | ||
code: "NOT_FOUND", | ||
}); | ||
} | ||
|
||
const date = parse(dateString, "MM/dd/yyyy", new Date()); | ||
if (!date) { | ||
throw new TRPCError({ | ||
message: `invalid date string ${dateString}`, | ||
code: "BAD_REQUEST", | ||
}); | ||
} | ||
const menu = await db.menu.findFirst({ | ||
where: { | ||
restaurantId: restaurant.id, | ||
date: date, | ||
period: period, | ||
}, | ||
}); | ||
if (!menu) { | ||
throw new TRPCError({ | ||
message: `menu not found`, | ||
code: "NOT_FOUND", | ||
}); | ||
} | ||
|
||
return menu; | ||
}); |
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,38 @@ | ||
import axios from "axios"; | ||
|
||
import { createTRPCRouter, publicProcedure } from "../../trpc"; | ||
import { getMenuProcedure } from "./get"; | ||
import { parseMenuProcedure } from "./parse"; | ||
|
||
// import { createTRPCRouter, publicProcedure } from "../trpc"; | ||
// import { parseCampusDish } from "./parse"; | ||
|
||
const helloProcedure = publicProcedure.query(async (opts) => { | ||
const res = await axios.get("https://jsonplaceholder.typicode.com/todos/1"); | ||
const _ = opts; | ||
console.log(res.data); | ||
console.log("hello"); | ||
return "hello"; | ||
}); | ||
|
||
export const menuRouter = createTRPCRouter({ | ||
get: getMenuProcedure, | ||
hello: helloProcedure, | ||
parse: parseMenuProcedure, | ||
// parse: publicProcedure.query(async ({ ctx }) => { | ||
// const res = await axios.get( | ||
// "https://uci-campusdish-com.translate.goog/api/menu/GetMenus?locationId=3314&periodId=49&date=1/19/2024", | ||
// ); | ||
// try { | ||
// const validated = CampusDishResponseSchema.parse(res.data); | ||
// const parsed = ParsedResponseSchema.parse(parseCampusDish(validated)); | ||
// const _ = ctx; | ||
// return parsed; | ||
// } catch (error) { | ||
// if (error instanceof z.ZodError) { | ||
// console.log(error.issues); | ||
// } | ||
// throw error; | ||
// } | ||
// }), | ||
}); |
Oops, something went wrong.