Last active
October 16, 2024 19:05
-
-
Save katychuang/f94b394551e03ec18c8b4e47d3bf4042 to your computer and use it in GitHub Desktop.
Revisions
-
katychuang revised this gist
Oct 16, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,11 +25,12 @@ app.get("/", (req, res, next) => { res.send("API end points include /one, /two"); }); // the `/one` endpoint showing hard coded json object app.get("/one", (req, res, next) => { res.status(200).json({"name": "one"}); }); // the `/two` endpoint app.post("/two", (req, res) => { res.status(200).json(req.body); }); -
katychuang revised this gist
Oct 16, 2024 . No changes.There are no files selected for viewing
-
katychuang revised this gist
Oct 15, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,4 @@ default: node api.js install: npm install express -
katychuang revised this gist
Oct 15, 2024 . 2 changed files with 1 addition and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,4 @@ default: node api.js install: npm install expressjs This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +0,0 @@ -
katychuang created this gist
Oct 15, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ const express = require("express"); const app = express(); const router = express.Router(); app.use(express.json()); const port = 3000; // Start server app.listen(port, () => { console.log("Server running on port %PORT%".replace("%PORT%",port)) }); // Insert here other API endpoints /* GET Requests / /one POST Requests /two */ // Root endpoint app.get("/", (req, res, next) => { res.send("API end points include /one, /two"); }); // List all records in top100 table app.get("/one", (req, res, next) => { res.status(200).json({"name": "one"}); }); app.post("/two", (req, res) => { res.status(200).json(req.body); }); // Default response for any other request app.use(function(req, res){ res.status(404); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ default: node api.js install: npm install expressjs This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ { "dependencies": { "express": "^4.19.2" } }