-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}; | ||
Check failure on line 10 in src/fibRoute.ts GitHub Actions / test
Check failure on line 10 in src/fibRoute.ts GitHub Actions / test
Check failure on line 10 in src/fibRoute.ts GitHub Actions / test
Check failure on line 10 in src/fibRoute.ts GitHub Actions / test
Check failure on line 10 in src/fibRoute.ts GitHub Actions / test
Check failure on line 10 in src/fibRoute.ts GitHub Actions / test
Check failure on line 10 in src/fibRoute.ts GitHub Actions / test
|
||
|
||
if (fibN < 0) { | ||
result = `fibonacci(${num}) is undefined`; | ||
} | ||
if (fibN < 0) { | ||
result = fibonacci(${num}) is undefined; | ||
Check failure on line 13 in src/fibRoute.ts GitHub Actions / test
Check failure on line 13 in src/fibRoute.ts GitHub Actions / test
Check failure on line 13 in src/fibRoute.ts GitHub Actions / test
|
||
} | ||
|
||
res.send(result); | ||
}; | ||
res.send(result); | ||
}; |