diff options
author | braxtonhall | 2022-10-23 18:20:39 +0000 |
---|---|---|
committer | braxtonhall | 2022-10-23 18:20:39 +0000 |
commit | b5b18e46e3a5c4daaa3b4613395b1a216a47bc17 (patch) | |
tree | 13312c71c0a2968cb34f86527a82bb1e33abb4b0 /entries/braxtonh/express/index.js |
Initial commit
Diffstat (limited to 'entries/braxtonh/express/index.js')
-rw-r--r-- | entries/braxtonh/express/index.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/entries/braxtonh/express/index.js b/entries/braxtonh/express/index.js new file mode 100644 index 0000000..2da6092 --- /dev/null +++ b/entries/braxtonh/express/index.js @@ -0,0 +1,22 @@ +import { get } from "axios"; +import express from "express"; + +const app = express(); + +const getURL = (n) => `/fib?${new URLSearchParams({n})}`; + +app.get("/fib", async (res, req, next) => { + const {n} = req.params; + if (n <= 0) { + res.send(n).status(200); + } else { + const futures = [get(getURL(n - 1)), get(getURL(n - 2))]; + const [nSub1, nSub2] = await Promise.all(futures); + res.send(nSub1 + nSub2).status(200); + } + return next(); +}); + +app.start(); + +// TODO... is this syntax correct??? |