Skip to content

Commit

Permalink
Add sept21 redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
JHWelch committed Sep 12, 2023
1 parent a8402db commit c8138e4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions __tests__/controllers/redirectController.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import RedirectController from '../../src/controllers/redirectController'
import { beforeEach, describe, expect, it } from '@jest/globals'
import { getMockReq, getMockRes } from '@jest-mock/express'

const { res, mockClear } = getMockRes()

beforeEach(() => {
mockClear()
})

describe('sep21', () => {
it('should return a redirect to notion', async () => {
const req = getMockReq()

await RedirectController.sept21(req, res)

expect(res.redirect)
.toHaveBeenCalledWith(RedirectController.sept21Url)
})
})
12 changes: 12 additions & 0 deletions src/controllers/redirectController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { type Request, type Response } from 'express'

export default class RedirectController {
static PATHS = {
sept21: '/sep21',
}
static sept21Url = 'https://ginger-flood-c72.notion.site/The-2023-Celebration-of-Rachel-s-32nd-Birthday-Also-Known-As-Halloween-in-September-a17c5537f8594c30bb301a48c988f7ec'

static async sept21 (_req: Request, res: Response): Promise<void> {
res.redirect(RedirectController.sept21Url)
}
}
2 changes: 2 additions & 0 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import FirestoreAdapter from './data/firestore/firestoreAdapter.js'
import TmdbAdapter from './data/tmdb/tmdbAdapter.js'
import RsvpController from './controllers/rsvpController.js'
import HealthCheckController from './controllers/healthCheckController.js'
import RedirectController from './controllers/redirectController.js'

export function registerRoutes (
express: Express,
Expand Down Expand Up @@ -54,6 +55,7 @@ function routes (
HttpMethod.POST,
),
new Route('/api/cache', cacheController.cache.bind(cacheController)),
new Route(RedirectController.PATHS.sept21, RedirectController.sept21),
]
}

Expand Down

0 comments on commit c8138e4

Please sign in to comment.