Skip to content

Instantly share code, notes, and snippets.

@treyhuffine
Created December 31, 2019 01:17
Show Gist options
  • Save treyhuffine/82b9ebe67facac026a999a222d030637 to your computer and use it in GitHub Desktop.
Save treyhuffine/82b9ebe67facac026a999a222d030637 to your computer and use it in GitHub Desktop.
import { Request, Response } from 'express';
interface HelloResponse {
hello: string;
}
type HelloBuilder = (name: string) => HelloResponse;
const helloBuilder: HelloBuilder = name => ({ hello: name });
export const rootHandler = (_req: Request, res: Response) => {
return res.send('API is working 🤓');
};
export const helloHandler = (req: Request, res: Response) => {
const { params } = req;
const { name = 'World' } = params;
const response = helloBuilder(name);
return res.json(response);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment