add echo path,
add cookie-parser to requirements Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
abefd36391
commit
a6b8ecf133
26
index.js
26
index.js
@ -1,21 +1,27 @@
|
|||||||
const express = require('express');
|
const express = require("express");
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require("body-parser");
|
||||||
const cors = require('cors');
|
const cookieParser = require("cookie-parser")
|
||||||
const helmet = require('helmet');
|
const cors = require("cors");
|
||||||
const morgan = require('morgan');
|
const helmet = require("helmet");
|
||||||
var package = require('./package.json');
|
const morgan = require("morgan");
|
||||||
|
var package = require("./package.json");
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
app.use(cookieParser())
|
||||||
app.use(cors());
|
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});
|
res.send({version: package.version});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(80, () => {
|
app.get("/api/echo", (req, res) => {
|
||||||
console.log('listening on port 80');
|
res.send({recieved: {body: req.body, cookies: req.cookies}});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(80, () => {
|
||||||
|
console.log("listening on port 80");
|
||||||
});
|
});
|
@ -5,6 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.20.1",
|
"body-parser": "^1.20.1",
|
||||||
|
"cookie-parser": "^1.4.6",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"helmet": "^6.0.1",
|
"helmet": "^6.0.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user