Skip to content

Commit

Permalink
Merge pull request #16 from dddwa/app-proxy-links
Browse files Browse the repository at this point in the history
Add in session proxy links for the app
  • Loading branch information
JakeGinnivan authored Nov 5, 2024
2 parents 9704adb + 4522c01 commit 292bcf5
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 2 deletions.
31 changes: 31 additions & 0 deletions website/app/routes/app-agenda-grid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { HeadersFunction, json, LoaderFunctionArgs } from '@remix-run/node'
import { TypeOf } from 'zod'
import { conferenceConfig } from '~/config/conference-config'
import { getYearConfig } from '~/lib/get-year-config'
import { CACHE_CONTROL } from '~/lib/http.server'
import { getScheduleGrid, gridSmartSchema } from '~/lib/sessionize.server'

export async function loader({ context }: LoaderFunctionArgs) {
const { yearConfig } = getYearConfig(context.conferenceState.conference.year, context.conferenceState.conference)

if (yearConfig.sessions?.kind === 'sessionize' && !yearConfig.sessions.sessionizeEndpoint) {
throw new Response(JSON.stringify({ message: 'No sessionize endpoint for year' }), { status: 404 })
}

const schedules: TypeOf<typeof gridSmartSchema> =
yearConfig.sessions?.kind === 'sessionize'
? await getScheduleGrid({
sessionizeEndpoint: yearConfig.sessions.sessionizeEndpoint,
confTimeZone: conferenceConfig.timezone,
})
: // TODO Deal with data type
[]

const schedule = schedules[0]

return json(schedule, { headers: { 'Cache-Control': CACHE_CONTROL.conf } })
}
export const headers: HeadersFunction = ({ loaderHeaders }) => {
// Inherit the caching headers from the loader so we don't cache 404s
return loaderHeaders
}
29 changes: 29 additions & 0 deletions website/app/routes/app-agenda-sessions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { HeadersFunction, json, LoaderFunctionArgs } from '@remix-run/node'
import { TypeOf } from 'zod'
import { conferenceConfig } from '~/config/conference-config'
import { getYearConfig } from '~/lib/get-year-config'
import { CACHE_CONTROL } from '~/lib/http.server'
import { getConfSessions, sessionsSchema } from '~/lib/sessionize.server'

export async function loader({ context }: LoaderFunctionArgs) {
const { yearConfig } = getYearConfig(context.conferenceState.conference.year, context.conferenceState.conference)

if (yearConfig.sessions?.kind === 'sessionize' && !yearConfig.sessions.sessionizeEndpoint) {
throw new Response(JSON.stringify({ message: 'No sessionize endpoint for year' }), { status: 404 })
}

const sessions: TypeOf<typeof sessionsSchema> =
yearConfig.sessions?.kind === 'sessionize'
? await getConfSessions({
sessionizeEndpoint: yearConfig.sessions.sessionizeEndpoint,
confTimeZone: conferenceConfig.timezone,
})
: []

return json(sessions, { headers: { 'Cache-Control': CACHE_CONTROL.conf } })
}

export const headers: HeadersFunction = ({ loaderHeaders }) => {
// Inherit the caching headers from the loader so we don't cache 404s
return loaderHeaders
}
29 changes: 29 additions & 0 deletions website/app/routes/app-agenda-speakers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { HeadersFunction, json, LoaderFunctionArgs } from '@remix-run/node'
import { TypeOf } from 'zod'
import { conferenceConfig } from '~/config/conference-config'
import { getYearConfig } from '~/lib/get-year-config'
import { CACHE_CONTROL } from '~/lib/http.server'
import { getConfSpeakers, speakersSchema } from '~/lib/sessionize.server'

export async function loader({ context }: LoaderFunctionArgs) {
const { yearConfig } = getYearConfig(context.conferenceState.conference.year, context.conferenceState.conference)

if (yearConfig.sessions?.kind === 'sessionize' && !yearConfig.sessions.sessionizeEndpoint) {
throw new Response(JSON.stringify({ message: 'No sessionize endpoint for year' }), { status: 404 })
}

const speakers: TypeOf<typeof speakersSchema> =
yearConfig.sessions?.kind === 'sessionize'
? await getConfSpeakers({
sessionizeEndpoint: yearConfig.sessions.sessionizeEndpoint,
confTimeZone: conferenceConfig.timezone,
})
: []

return json(speakers, { headers: { 'Cache-Control': CACHE_CONTROL.conf } })
}

export const headers: HeadersFunction = ({ loaderHeaders }) => {
// Inherit the caching headers from the loader so we don't cache 404s
return loaderHeaders
}
9 changes: 9 additions & 0 deletions website/app/routes/app-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export function loader({ context }: LoaderFunctionArgs) {
home: {
after: 'https://raw.githubusercontent.com/dddwa/dddperth/refs/heads/main/website-content/pages/post-conference.mdx',
},
v2: {
support: 'https://dddperth.com/app-content/support',
after: 'https://dddperth.com/app-content/post-conference',
},
}

return json(data, {
Expand All @@ -26,4 +30,9 @@ interface AppConfig {
home: {
after: string
}

v2: {
support: string
after: string
}
}
File renamed without changes.
22 changes: 20 additions & 2 deletions website/remix-routes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ declare module "remix-routes" {
query: ExportedQuery<import('app/routes/_layout.agenda.$year.talk.$sessionId').SearchParams>,
};

"/app-agenda-grid": {
params: never,
query: ExportedQuery<import('app/routes/app-agenda-grid').SearchParams>,
};

"/app-agenda-sessions": {
params: never,
query: ExportedQuery<import('app/routes/app-agenda-sessions').SearchParams>,
};

"/app-agenda-speakers": {
params: never,
query: ExportedQuery<import('app/routes/app-agenda-speakers').SearchParams>,
};

"/app-config": {
params: never,
query: ExportedQuery<import('app/routes/app-config').SearchParams>,
Expand All @@ -48,7 +63,7 @@ declare module "remix-routes" {
params: {
"*": string | number;
} ,
query: ExportedQuery<import('app/routes/_layout.app-content.$').SearchParams>,
query: ExportedQuery<import('app/routes/app-content.$').SearchParams>,
};

"/blog": {
Expand Down Expand Up @@ -84,10 +99,13 @@ declare module "remix-routes" {
| 'routes/_layout.$'
| 'routes/_layout.agenda.($year)'
| 'routes/_layout.agenda.$year.talk.$sessionId'
| 'routes/_layout.app-content.$'
| 'routes/_layout.blog._index'
| 'routes/_layout.blog.$slug'
| 'routes/app-agenda-grid'
| 'routes/app-agenda-sessions'
| 'routes/app-agenda-speakers'
| 'routes/app-config'
| 'routes/app-content.$'
| 'routes/blog.rss[.xml]';

export function $path<
Expand Down

0 comments on commit 292bcf5

Please sign in to comment.