add echo path,

add cookie-parser to requirements

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-01-19 20:22:26 +00:00
parent ab027bf278
commit 5b03a331ea
2 changed files with 16 additions and 9 deletions

View File

@ -1,21 +1,27 @@
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const helmet = require('helmet');
const morgan = require('morgan');
var package = require('./package.json');
const express = require("express");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser")
const cors = require("cors");
const helmet = require("helmet");
const morgan = require("morgan");
var package = require("./package.json");
const app = express();
app.use(helmet());
app.use(bodyParser.json());
app.use(cookieParser())
app.use(cors());
app.use(morgan('combined'));
app.use(morgan("combined"));
app.get('/api/version', (req, res) => {
app.get("/api/version", (req, res) => {
res.send({version: package.version});
});
app.get("/api/echo", (req, res) => {
res.send({recieved: {body: req.body, cookies: req.cookies}});
});
app.listen(80, () => {
console.log('listening on port 80');
console.log("listening on port 80");
});

View File

@ -5,6 +5,7 @@
"main": "index.js",
"dependencies": {
"body-parser": "^1.20.1",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"express": "^4.18.2",
"helmet": "^6.0.1",