5b03a331ea
add cookie-parser to requirements Signed-off-by: Arthur Lu <learthurgo@gmail.com>
27 lines
686 B
JavaScript
27 lines
686 B
JavaScript
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.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");
|
|
}); |