Skip to content

Commit

Permalink
fixed route return
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Dec 8, 2023
1 parent 4a552b2 commit 6d9b611
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
.vscode
tsconfig.tsbuildinfo

# dependencies
/node_modules
Expand Down
29 changes: 2 additions & 27 deletions app/api/library-hours/route.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
import {deserialize} from "@/lib/drupal/deserialize";
import {NextResponse} from "next/server";
import {DayHours} from "@/lib/hooks/useLibraryHours";
import {LibraryHours} from "@/lib/drupal/drupal";

export type LibraryHours = {
type: string
id: string
name: string
primary_location: string
locations: {
type: string
id: string
name: string
primary: boolean
hours: DayHours[]
links: {
self: string
}
library: {
type: string
id: string
name: string
primary_location: string
hours: DayHours[]
links: [Object]
locations: []
}
}[]
hours: DayHours[]
}

type FetchedData = {
data: []
Expand All @@ -53,7 +28,7 @@ export const GET = async () => {

const deserializedData = deserialize(data) as LibraryHours[];
if (!deserializedData) {
return [];
return NextResponse.json([]);
}

const locations: Record<string, {
Expand Down
29 changes: 29 additions & 0 deletions src/lib/drupal/drupal.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {DrupalFile, DrupalMedia, DrupalNode, DrupalParagraph, DrupalTaxonomyTerm} from "next-drupal";
import {JsonApiResource} from "next-drupal";
import {DayHours} from "@/lib/hooks/useLibraryHours";

export type StanfordNode = BasicPage |
Course |
Expand Down Expand Up @@ -484,3 +485,31 @@ export type Breadcrumb = {
href: string
text: string
}


export type LibraryHours = {
type: string
id: string
name: string
primary_location: string
locations: {
type: string
id: string
name: string
primary: boolean
hours: DayHours[]
links: {
self: string
}
library: {
type: string
id: string
name: string
primary_location: string
hours: DayHours[]
links: [Object]
locations: []
}
}[]
hours: DayHours[]
}

0 comments on commit 6d9b611

Please sign in to comment.