Skip to content

Commit

Permalink
Merge pull request #23 from pwnsoni/feature1
Browse files Browse the repository at this point in the history
exchanged express-session with cookie-session
  • Loading branch information
Rajan authored Apr 18, 2019
2 parents 305b6a3 + 830322a commit 9a50464
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 7 deletions.
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"bootstrap-vue": "^2.0.0-rc.18",
"bootswatch": "^4.3.1",
"cookie-parser": "^1.4.4",
"cookie-session": "^1.3.3",
"cors": "^2.8.5",
"cross-env": "^5.2.0",
"dot-env": "0.0.1",
Expand Down
30 changes: 24 additions & 6 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const consola = require("consola");
const { Nuxt, Builder } = require("nuxt");
const cors = require("cors");
const bodyParser = require("body-parser");
const session = require('express-session');
// const session = require('express-session');
const session = require("cookie-session");
const mongoose = require("mongoose");
const initDb = require("./db");

Expand Down Expand Up @@ -36,20 +37,37 @@ async function start() {
const queryParams = { id: req.params.id };
app.render(req, res, actualPage, queryParams);
});



// app.get('*', (req, res) => nuxt(req, res))


// Sessions to create `req.session`
// app.use(session({
// secret: 'super-secret-key',
// resave: true,
// saveUninitialized: false,
// cookie: { maxAge: 1000 * 60 * 60 }
// }));


app.use(session({
name : 'session',
secret: 'super-secret-key',
resave: true,
saveUninitialized: false,
cookie: { maxAge: 1000 * 60 * 60 }
}));
maxAge: 1000 * 60 * 60
}));




const routes = require("./routes");

app.use("/api", [cors(), bodyParser.json()], routes);

console.log('API routes: ' + routes);
console.log('API routes: ' + JSON.stringify(routes.stack));
// console.log('Api routes', routes);


// POST `/api/logout` to log out the user and remove it from the `req.session`
app.post('/api/logout', function (req, res) {
Expand Down
33 changes: 32 additions & 1 deletion static/sw.js
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
// THIS FILE SHOULD NOT BE VERSION CONTROLLED
importScripts('https://cdn.jsdelivr.net/npm/[email protected]/workbox/workbox-sw.js')

// --------------------------------------------------
// Configure
// --------------------------------------------------

// Set workbox config
workbox.setConfig({
"debug": false
})

// Start controlling any existing clients as soon as it activates
workbox.core.clientsClaim()

// Skip over the SW waiting lifecycle stage
workbox.core.skipWaiting()

workbox.precaching.cleanupOutdatedCaches()

// --------------------------------------------------
// Precaches
// --------------------------------------------------

// Precache assets

// --------------------------------------------------
// Runtime Caching
// --------------------------------------------------

// Register route handlers for runtimeCaching
workbox.routing.registerRoute(new RegExp('/_nuxt/(?!.*(__webpack_hmr|hot-update))'), new workbox.strategies.CacheFirst ({}), 'GET')
workbox.routing.registerRoute(new RegExp('/(?!.*(__webpack_hmr|hot-update))'), new workbox.strategies.NetworkFirst ({}), 'GET')

0 comments on commit 9a50464

Please sign in to comment.