var express = require("@runkit/runkit/express-endpoint/1.0.0");
var cors = require("cors");
var app = express(exports);
var session = require('express-session');
app.set('trust proxy', 1);
app.use(session({
secret: 'NAuwsBgNG3VmEjhoL40XCcPIhb2CfQY3IGBaTHbA0ft7hx6rxn9SErSm19vJyM4JXCvitloUscnaksMJ6mqDyyxKKzXALPdudg3ysW',
resave: false,
saveUninitialized: true,
name: "sessid",
cookie: {
secure: true,
sameSite: "none", // This needs to be 'none' if support for cross-site requests are needed.
/* maxAge: 60*60*1000, // For session cookie, don't set this property */
/* rolling: true, // Specify this only if specifying the maxAge property */
httpOnly: true
}
}));
function process(req, res){
var data = req.session.data;
if(!data){
data = Math.random();
req.session.data = data;
}
res.status(200);
res.json({"data": data});
}
app.use(cors({
origin: "*", // set specific origin if credentials (i.e. cookie) needs to be supported "https://www.example.com",
//credentials: true, // set this to true if cookies need to be supported.
allowedHeaders: "*",
optionsSuccessStatus: 200
}));
app.get("/", (req, res) => {process(req, res);});