fix: mixin

This commit is contained in:
cha0s 2024-01-05 22:49:02 -06:00
parent c8a6f68628
commit 2f6ed6a0c8
4 changed files with 10 additions and 7 deletions

View File

@ -117,8 +117,8 @@ export const hooks = {
/** /**
* Invoked when the application is starting. Use for order-independent initialization tasks. * Invoked when the application is starting. Use for order-independent initialization tasks.
*/ */
'@flecks/core.starting': (flecks) => { '@flecks/core.starting': () => {
flecks.set('$my-fleck/value', initializeMyValue()); console.log('starting!');
}, },
/** /**

View File

@ -780,3 +780,6 @@ export default class Flecks {
} }
} }
Flecks.get = get;
Flecks.set = set;

View File

@ -23,14 +23,14 @@ const {version} = require('../package.json');
debug('starting server...'); debug('starting server...');
// Make resolver. // Make resolver.
// Flecks mixins. // Flecks mixins.
const resolver = BaseFlecks.makeResolver(config);
const rcs = BaseFlecks.loadRcs(resolver);
BaseFlecks.installCompilers(rcs, resolver);
const flecks = await loadFlecks(); const flecks = await loadFlecks();
const mixins = Object.entries(flecks) const mixins = Object.entries(flecks)
.map(([, M]) => M.hooks?.['@flecks/core.mixin']) .map(([, M]) => M.hooks?.['@flecks/core.mixin'])
.filter((e) => e); .filter((e) => e);
const Flecks = compose(...mixins)(BaseFlecks); const Flecks = compose(...mixins)(BaseFlecks);
const resolver = Flecks.makeResolver(config);
const rcs = Flecks.loadRcs(resolver);
Flecks.installCompilers(rcs, resolver);
global.flecks = new Flecks({ global.flecks = new Flecks({
config, config,
flecks, flecks,

View File

@ -1,6 +1,6 @@
import {D} from '@flecks/core'; import {D} from '@flecks/core';
import express from 'express'; import express from 'express';
import user.session from 'express-session'; import expressSession from 'express-session';
const debug = D('@flecks/user/session'); const debug = D('@flecks/user/session');
const debugSilly = debug.extend('silly'); const debugSilly = debug.extend('silly');
@ -47,7 +47,7 @@ export const hooks = {
}; };
}, },
'@flecks/server.up': async (flecks) => { '@flecks/server.up': async (flecks) => {
flecks.user.session = user.session({ flecks.user.session = expressSession({
resave: false, resave: false,
sameSite: true, sameSite: true,
saveUninitialized: false, saveUninitialized: false,