tangled
alpha
login
or
join now
thecoded.prof
/
CMU
0
fork
atom
CMU Coding Bootcamp
0
fork
atom
overview
issues
pulls
pipelines
feat: add gateway.ts
thecoded.prof
1 month ago
b3903c3a
6e6447bd
verified
This commit was signed with the committer's
known signature
.
thecoded.prof
SSH Key Fingerprint:
SHA256:ePn0u8NlJyz3J4Zl9MHOYW3f4XKoi5K1I4j53bwpG0U=
+26
-1
2 changed files
expand all
collapse all
unified
split
server
books.ts
gateway.ts
+1
-1
server/books.ts
···
368
});
369
370
router.get("/find", async (req, res) => {
371
-
res.locals.query = req.params as Partial<BooksQuery>;
372
const books = filterBooks(res.locals.query);
373
res.json(books);
374
});
···
368
});
369
370
router.get("/find", async (req, res) => {
371
+
res.locals.query = req.query as Partial<BooksQuery>;
372
const books = filterBooks(res.locals.query);
373
res.json(books);
374
});
+25
server/gateway.ts
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
import express from "express";
2
+
3
+
const app = express();
4
+
5
+
app.get("/books/:id", async (req, res) => {
6
+
const { id } = req.params;
7
+
const book = await fetch(`localhost:5713/books/${id}`);
8
+
const body = await book.json();
9
+
res.send(body);
10
+
});
11
+
12
+
app.get("/tasks/:id", async (req, res) => {
13
+
const { id } = req.params;
14
+
const task = await fetch(`localhost:5713/tasks/${id}`);
15
+
const body = await task.json();
16
+
res.send(body);
17
+
});
18
+
19
+
app.all("/*splat", (req, res) => {
20
+
res.status(404).send("Not Found");
21
+
});
22
+
23
+
app.listen(3000, () => {
24
+
console.log("Server started on port 3000");
25
+
});