diff --git a/src/fibRoute.ts b/src/fibRoute.ts index 7edb130..647d551 100644 --- a/src/fibRoute.ts +++ b/src/fibRoute.ts @@ -1,14 +1,17 @@ -import { Request, Response } from "express"; +import { Request, Response } from 'express'; +import fibonacci from './fib'; +// Endpoint for querying the fibonacci numbers export default (req: Request, res: Response) => { - const { num } = req.params as { num: string }; // Explicitly typing `num` as a string +const { num } = req.params as { num: string }; - const fibN = fibonacci(parseInt(num)); - let result = `fibonacci(${num}) is ${fibN}`; +const parsedNum: number = parseInt(num, 10); +const fibN: number = fibonacci(parsedNum); +let result = fibonacci(${num}) is ${fibN}; - if (fibN < 0) { - result = `fibonacci(${num}) is undefined`; - } +if (fibN < 0) { +result = fibonacci(${num}) is undefined; +} - res.send(result); -}; +res.send(result); +}; \ No newline at end of file