UNPKG

@foal/core

Version:

Full-featured Node.js framework, with no complexity

22 lines (21 loc) 767 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSession = createSession; const common_1 = require("../../common"); const session_1 = require("./session"); async function createSession(store) { const date = Math.floor(Date.now() / 1000); const state = { content: { csrfToken: await (0, common_1.generateToken)(), }, createdAt: date, // The below line cannot be tested because of the encapsulation of Session. flash: {}, id: await (0, common_1.generateToken)(), // Any value here is fine. updatedAt is set by Session.commit(). updatedAt: date, userId: null, }; return new session_1.Session(store, state, { exists: false }); }