Skip to content

Commit

Permalink
fix: create session in viewData
Browse files Browse the repository at this point in the history
  • Loading branch information
ernscht committed Nov 2, 2023
1 parent 159ee1c commit e3ac16a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const cookieSession = require('cookie-session');
const utils = require('@nitro/app/app/lib/utils');

const validThemes = utils.getValidThemes();
Expand All @@ -12,13 +11,6 @@ const validThemes = utils.getValidThemes();
module.exports = (app) => {
if (app.get('env') === 'production') {
if (validThemes) {
app.use(
cookieSession({
name: 'theme',
keys: ['keeeeeeeeeeey', 'schlüssel'],
}),
);

for (const theme of validThemes) {
app.route(`/theme/${theme.id}`).get((req, res, next) => {
req.session.theme = theme.id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const cookieSession = require('cookie-session');
const extend = require('extend');
const utils = require('@nitro/app/app/lib/utils');
const view = require('@nitro/app/app/lib/view');
Expand Down Expand Up @@ -35,6 +36,14 @@ function theme(req, res, next) {

module.exports = (app) => {
if (validThemes) {
if (app.get('env') === 'production') {
app.use(
cookieSession({
name: 'theme',
keys: ['keeeeeeeeeeey', 'schlüssel'],
}),
);
}
app.route('*').all(theme);
}
};
8 changes: 0 additions & 8 deletions packages/project-nitro/project/routes/_themes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const cookieSession = require('cookie-session');
const utils = require('@nitro/app/app/lib/utils');

const validThemes = utils.getValidThemes();
Expand All @@ -12,13 +11,6 @@ const validThemes = utils.getValidThemes();
module.exports = (app) => {
if (app.get('env') === 'production') {
if (validThemes) {
app.use(
cookieSession({
name: 'theme',
keys: ['keeeeeeeeeeey', 'schlüssel'],
}),
);

for (const theme of validThemes) {
app.route(`/theme/${theme.id}`).get((req, res, next) => {
req.session.theme = theme.id;
Expand Down
9 changes: 9 additions & 0 deletions packages/project-nitro/project/viewData/_themes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const cookieSession = require('cookie-session');
const extend = require('extend');
const utils = require('@nitro/app/app/lib/utils');
const view = require('@nitro/app/app/lib/view');
Expand Down Expand Up @@ -35,6 +36,14 @@ function theme(req, res, next) {

module.exports = (app) => {
if (validThemes) {
if (app.get('env') === 'production') {
app.use(
cookieSession({
name: 'theme',
keys: ['keeeeeeeeeeey', 'schlüssel'],
}),
);
}
app.route('*').all(theme);
}
};

0 comments on commit e3ac16a

Please sign in to comment.