-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Enable full strict mode for tsc
- Loading branch information
Showing
14 changed files
with
45 additions
and
32 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
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
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,15 +1,19 @@ | ||
import type { Request, Response } from 'express'; | ||
import type { ReactElement } from 'react'; | ||
|
||
export type RouteHandler = (req: Request, res: Response & { render: Render }) => void; | ||
export type UIRouteHandler = ( | ||
req: Request, | ||
res: { [key in keyof Response as key extends 'render' ? never : key]: Response[key] } & { render: Render } | ||
) => void; | ||
|
||
// Note: This isn't the actual type that's imported, but since we override render to support JSX... | ||
export type APIRoute = { | ||
handler: RouteHandler; | ||
handler: (req: Request, res: Response) => void; | ||
verb?: 'get' | 'post'; | ||
}; | ||
|
||
export type UIRoute = { | ||
handler: RouteHandler; | ||
handler: (req: Request, res: Response) => void; | ||
}; | ||
|
||
export type Render = (jsx: ReactElement, title: string, hydrate: boolean) => Promise<Response>; |
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,10 +1,14 @@ | ||
import { getAllQuotes } from '@/database/quotes'; | ||
|
||
import type { RouteHandler } from '@/types/web'; | ||
import type { RequestHandler } from 'express'; | ||
|
||
export const handler: RouteHandler = async (req, res) => { | ||
export const handler: RequestHandler = async (req, res) => { | ||
const { room } = req.params as { room: string }; | ||
const quotes = await getAllQuotes(room); | ||
if (!quotes.length) return res.sendStatus(404); | ||
return res.json(quotes); | ||
if (!quotes.length) { | ||
// https://github.com/microsoft/TypeScript/issues/12871 | ||
res.sendStatus(404); | ||
return; | ||
} | ||
res.json(quotes); | ||
}; |
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,7 +1,7 @@ | ||
import type { RouteHandler } from '@/types/web'; | ||
import type { UIRouteHandler } from '@/types/web'; | ||
|
||
const Div = () => <div>Test content here; fully static</div>; | ||
|
||
export const handler: RouteHandler = (req, res) => { | ||
return res.render(<Div />, 'Test Title', false); | ||
export const handler: UIRouteHandler = (req, res) => { | ||
res.render(<Div />, 'Test Title', false); | ||
}; |
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