Minor fixes
This commit is contained in:
@@ -58,7 +58,7 @@ const getRegion = async (
|
||||
res.status(404).send("Not found");
|
||||
}
|
||||
} catch (e) {
|
||||
res.status(500).send("Server error 1");
|
||||
res.status(500).send("Server error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ const deleteRegion = async (
|
||||
|
||||
const result = await dbConn.query(deleteRegion);
|
||||
if (result.info.affectedRows > 0) {
|
||||
res.status(204).send("Region deleted");
|
||||
res.status(204).send();
|
||||
} else {
|
||||
res.status(404).send("Region not found");
|
||||
}
|
||||
@@ -170,7 +170,7 @@ const putRegion = async (
|
||||
const result = await dbConn.query(sqlUpdateRegion);
|
||||
|
||||
if (result.info.affectedRows > 0) {
|
||||
res.status(204).send("Region updated");
|
||||
res.status(204).send();
|
||||
} else {
|
||||
res.status(409).send("Region not updated");
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ app.get("/", (req, res) => res.send("Secure server!"));
|
||||
|
||||
/*
|
||||
Add here the logic for CORS
|
||||
*/
|
||||
|
||||
const cors = require("cors");
|
||||
app.use(cors());
|
||||
*/
|
||||
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
|
||||
@@ -31,8 +32,11 @@ const {
|
||||
|
||||
app.get("/regions/", (req, res) => getRegion(res, dbConn));
|
||||
|
||||
app.get("/regions/:country/", (req, res) =>
|
||||
getRegion(res, dbConn, req.params.country)
|
||||
app.get(
|
||||
"/regions/:country/",
|
||||
(req, res) => (
|
||||
console.log(req), getRegion(res, dbConn, req.params.country)
|
||||
)
|
||||
);
|
||||
|
||||
app.get("/regions/:country/:region/", (req, res) =>
|
||||
@@ -65,7 +69,6 @@ app.use((err, req, res, next) => {
|
||||
|
||||
/*
|
||||
Add here the logic for HTTPS
|
||||
*/
|
||||
|
||||
const https = require("https");
|
||||
const fs = require("fs");
|
||||
@@ -76,3 +79,9 @@ const cert = fs.readFileSync(`${keysPath}/modernjsbook.crt`);
|
||||
const key = fs.readFileSync(`${keysPath}/modernjsbook.key`);
|
||||
|
||||
https.createServer({ ca, cert, key }, app).listen(8443);
|
||||
|
||||
and remove the following line if HTTPS is used
|
||||
*/
|
||||
app.listen(8080, () =>
|
||||
console.log("Routing ready at http://localhost:8080")
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user