diff --git a/README.md b/README.md index 6230db5..f4abf21 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ import {Hooks} from '@flecks/core'; export default { [Hooks]: { - '@flecks/core/starting': () => { + '@flecks/core.starting': () => { console.log('hello, gorgeous'); }, }, @@ -149,14 +149,14 @@ you the way you deserve to be treated. Just to give you an idea of the power of hooks, some will be listed here: -- `@flecks/core/config`: +- `@flecks/core.config`: > Define default configuration. -- `@flecks/docker/containers`: +- `@flecks/docker.containers`: > Define [Docker](https://www.docker.com/) containers to run alongside your application to develop e.g. DB models, redis commands, etc. without having to worry about installing stuff. -- `@flecks/http/server/request.route`: +- `@flecks/http/server.request.route`: > Define [Express](http://expressjs.com/) middleware that runs when an HTTP route is hit. -- `@flecks/server/up`: +- `@flecks/server.up`: > Do things when server comes up (e.g. DB connection, HTTP listener, make you coffee, etc). ...and so many more. diff --git a/TODO.md b/TODO.md index 181ceb0..563b9dd 100644 --- a/TODO.md +++ b/TODO.md @@ -22,4 +22,4 @@ - [ ] autogenerated config dox page - [x] remove `invokeParallel()` - [x] Specialize `invokeReduce()` with `invokeMerge()`. -- [ ] Rename all hooks to dot-first notation; rewrite `lookupFlecks()`. \ No newline at end of file +- [x] Rename all hooks to dot-first notation; rewrite `lookupFlecks()`. \ No newline at end of file diff --git a/packages/core/build/dox/concepts/hooks.md b/packages/core/build/dox/concepts/hooks.md new file mode 100755 index 0000000..1466b50 --- /dev/null +++ b/packages/core/build/dox/concepts/hooks.md @@ -0,0 +1,325 @@ +# Hooks + +Hooks are how everything happens in flecks. There are many hooks and the hooks provided by flecks are documented at the [hooks reference page](ADDME). + +To define hooks (and turn your plain ol' boring JS modules into beautiful interesting flecks), you only have to import the `Hooks` symbol and key your default export: + +```javascript +import {Hooks} from '@flecks/core'; + +export default { + [Hooks]: { + '@flecks/core.starting': () => { + console.log('hello, gorgeous'); + }, + }, +}; +``` + +**Note:** All hooks recieve an extra final argument, which is the flecks instance. + +## Types + +  + +### `invoke(hook, ...args)` + +Invokes all hook implementations and returns the results keyed by the implementing flecks' paths. + +  + +### `invokeComposed(hook, initial, ...args)` +### `invokeComposedAsync(hook, initial, ...args)` + +See: [function composition](https://www.educative.io/edpresso/function-composition-in-javascript). + +`initial` is passed to the first implementation, which returns a result which is passed to the second implementation, which returns a result which is passed to the third implementation, etc. + +Composed hooks are ordered. + +  + +### `invokeFlat(hook, ...args)` + +Invokes all hook implementations and returns the results as an array. + +  + +### `invokeFleck(hook, fleck, ...args)` + +Invoke a single fleck's hook implementation and return the result. + +  + +### `invokeMerge(hook, ...args)` +### `invokeMergeAsync(hook, ...args)` + +Invokes all hook implementations and returns the result of merging all implementations' returned objects together. + +  + +### `invokeReduce(hook, reducer, initial, ...args)` +### `invokeReduceAsync(hook, reducer, initial, ...args)` + +See: [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) + +Invokes hook implementations one at a time, their results being passed to the reducer as `currentValue`. Returns the final reduction. + +  + +### `invokeSequential(Async)?(hook, ...args)` + +Invokes all hook implementations, one after another. In the async variant, each implementation's result is `await`ed before invoking the next implementation. + +Sequential hooks are ordered. + +  + +## Idioms + +### `flecks.gather(hook, options)` + +Gathering is useful when your fleck defines some sort of specification, and then expects its sibling flecks to actually implement it. Examples of this in flecks would be: + +- Models, defined through `@flecks/db/server.models`. +- Packets, defined through `@flecks/socket.packets`. + +One constraint of using `flecks.gather()` is that whatever you are gathering must be able to be extended as a class. You can't `flecks.gather()` plain objects, numbers, strings... you get the idea. + +The most basic usage: + +```javascript +const Gathered = flecks.gather('my-gather-hook'); +``` + +Suppose `my-gather-hook` above resulted in gathering two classes, `Foo` and `Bar`. In this case, `Gathered` would be such as: + +```javascript +import {ById, ByType} from '@flecks/core'; + +const Gathered = { + 1: Bar, + 2: Foo, + 'Bar': Bar, + 'Foo': Foo, + [ById]: { + 1: Bar, + 2: Foo, + }, + [ByType]: { + 'Bar': Bar, + 'Foo': Foo, + }, +}; +``` + +`flecks.gather()` gives each of your classes a numeric (nonzero) ID as well as a type name. It also merges all numeric keys and type labels together into the result, so `Gathered[1] === Gathered.Bar` would evaluate to `true` in the example above. + +The symbol keys `ById` and `ByType` are useful if you need to iterate over *either* all IDs or all types. Since the numeric IDs and types are merged, iterating over the entire `Gathered` object would otherwise result in duplicates. + +Each class gathered by `flecks.gather()` will be extended with two properties by default: `id` and `type`. These correspond to the ID and type referenced above, and are useful for e.g. serialization. + +Following from the example above: + +```javascript +const foo = new Gathered.Foo(); +assert(foo.id === 2); +assert(foo.type === 'Foo); +``` + +`flecks.gather()` also supports some options: + +```javascript +{ + // The property added when extending the class to return the numeric ID. + idAttribute = 'id', + // The property added when extending the class to return the type. + typeAttribute = 'type', + // A function called with the `Gathered` object to allow checking validity. + check = () => {}, +} +``` + +As an example, when `@flecks/db/server` gathers models, `typeAttribute` is set to `name`, because Sequelize requires its model classes to have a unique `name` property. + +**Note:** the numeric IDs are useful for efficient serialization between the client and server, but **if you are using this property, ensure that `flecks.gather()` is called equivalently on both the client and the server**. As a rule of thumb, if you have serializable `Gathered`s, they should be invoked and defined in `your-fleck`, and not in `your-fleck/[platform]`, so that they are invoked for every platform. + +#### `Flecks.provide(context, options)` + +Complementary to gather hooks above, `Flecks.provide()` allows you to ergonomically provide your flecks' implementations to a gather hook. + +Here's an example of how you could manually provide `@flecks/db/server.models` in your own fleck: + +```javascript +import {Hooks} foom '@flecks/core'; + +import SomeModel from './models/some-model'; +import AnotherModel from './models/another-model'; + +export default { + [Hooks]: { + '@flecks/db/server.models': () => ({ + SomeModel, + AnotherModel, + }), + }, +}; +``` + +If you think about the example above, you might realize that it will become a lot of typing to keep adding new models over time. Provider hooks exist to reduce this maintenance burden for you. + +Webpack provides an API called [require.context](https://v4.webpack.js.org/guides/dependency-management/#requirecontext), and the flecks provider is optimized to work with this API. + +Supposing our fleck is structured like so: + +``` +index.js +models/ +├─ some-model.js +└─ another-model.js +``` + +then, this `index.js`: + +```javascript +import {Flecks, Hooks} from '@flecks/core'; + +export default { + [Hooks]: { + '@flecks/db/server.models': Flecks.provide(require.context('./models', false, /\.js$/)), + }, +}; +``` + +is *exactly equivalent* to the gather example above. By default, `Flecks.provide()` *CamelCase*s the paths, so `some-model` becomes `SomeModel`, just as in the example above. + +`Flecks.provide()` also supports some options: + +```javascript +{ + // The transformation used on the class path. + transformer = camelCase, +} +``` + +**Note:** There is no requirement to use `Flecks.provide()`, it is merely a convenience. + +### Decorator hooks + +When a Model (or any other) is gathered as above, an implicit hook is called: `${hook}.decorate`. This allows other flecks to decorate whatever has been gathered: + +```javascript +import {Hooks} from '@flecks/core'; + +export default { + [Hooks]: { + '@flecks/db/server.models.decorate': (Models) => { + return { + ...Models, + User: class extends Models.User { + + // Let's mix in some logging... + constructor(...args) { + super(...args); + console.log ('Another user decorated!'); + } + + }, + }; + }, + }, +}; +``` + +#### `Flecks.decorate(context, options)` + +As with above, there exists an API for making the maintenance of decorators more ergonomic. + +Supposing our fleck is structured like so: + +``` +index.js +models/ +└─ decorators/ + └─ user.js +``` + +and supposing that `./models/decorators/user.js` is written like so: + +```javascript +export default (User) => { + return class extends User { + + // Let's mix in some logging... + constructor(...args) { + super(...args); + console.log ('Another user decorated!'); + } + + }; +}; +``` + +then, this `index.js`: + +```javascript +import {Flecks, Hooks} from '@flecks/core'; + +export default { + [Hooks]: { + '@flecks/db/server.models.decorate': Flecks.decorate(require.context('./models/decorators', false, /\.js$/)), + }, +}; +``` + +is *exactly equivalent* to the decorator example above. + +`Flecks.decorate()` also supports some options: + +```javascript +{ + // The transformation used on the class path. + transformer = camelCase, +} +``` + +Decorator hooks are ordered. + +## Ordered hooks + +In many of the instances above, reference was made to the fact that certain hook types are "ordered". + +Suppose we are composing an application and we have HTTP session state using cookies. When a user hits a route, we need to load their session and subsequently read a value from said session to determine if the user prefers dark mode. Clearly, we will have to ensure that the session reification happens first. This is one function of ordered hooks. + +Flecks uses the name of the hook as a configuration key in order to determine the ordering of a hook. Let's take the hook we alluded to earlier as an example, `@flecks/http/server.request.route`: + +Our `flecks.yml` could be configured like so: + +```yaml +'@flecks/http/server': + 'request.route': + - '@flecks/user/session' + - 'my-cool-fleck' +``` + +In this application, when `@flecks/http/server.request.route` is invoked, `@flecks/user/session`'s implementation is invoked (which reifies the user's session from cookies), followed by `my-cool-fleck`'s (which, we assume, does some kind of very cool dark mode check). + +It may not always be ergonomic to configure the order of every single implementation, but enough to specify which implementations must run first (or last). + +For example, suppose we have multiple implementations that require there to have been a reified user session, but which order those implementations run might not be a concern. For this, flecks provides you with the ellipses entry: + +```yaml +'@flecks/http/server': + 'request.route': + - '@flecks/user/session' + - '...' + - 'some-final-fleck' +``` + +In this application, we first reify the user session as before, but instead of listing `my-cool-fleck` immediately after, we specify ellipses. After the ellipses we specify `some-final-fleck` to, we assume, do some finalization work. + +Ellipses essentially translate to: "every implementing fleck which has not already been explicitly listed in the ordering configuration". + +Using more than one ellipses entry in an ordering configuration is ambiguous and will throw an error. + +The default ordering configuration for any ordered hook is: `['...']` which translates to all implementations in an undefined order. \ No newline at end of file diff --git a/packages/core/build/dox/hooks.js b/packages/core/build/dox/hooks.js index 08d17be..04043e9 100644 --- a/packages/core/build/dox/hooks.js +++ b/packages/core/build/dox/hooks.js @@ -7,7 +7,7 @@ export default { * @param {string} target The build target; e.g. `server`. * @param {Object} config The neutrino configuration. */ - '@flecks/core/build': (target, config) => { + '@flecks/core.build': (target, config) => { if ('something' === target) { config[target].use.push(someNeutrinoMiddleware); } @@ -17,7 +17,7 @@ export default { * Alter build configurations after they have been hooked. * @param {Object} configs The neutrino configurations. */ - '@flecks/core/build/alter': (configs) => { + '@flecks/core.build.alter': (configs) => { // Maybe we want to do something if a config exists..? if (configs.something) { // Do something... @@ -29,7 +29,7 @@ export default { /** * Define CLI commands. */ - '@flecks/core/commands': (program) => ({ + '@flecks/core.commands': (program) => ({ // So this could be invoked like: // npx flecks something -t --blow-up blah something: { @@ -50,7 +50,7 @@ export default { /** * Define configuration. */ - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ whatever: 'configuration', your: 1337, fleck: 'needs', @@ -58,43 +58,43 @@ export default { }), /** - * Invoked when a gathered class is HMR'd. - * @param {constructor} Class The class. - * @param {string} hook The gather hook; e.g. `@flecks/db/server/models`. - */ - '@flecks/core/gathered/hmr': (Class, hook) => { - // Do something with Class... - }, - - /** - * Invoked when a fleck is HMR'd - * @param {string} path The path of the fleck - * @param {Module} updatedFleck The updated fleck module. - */ - '@flecks/core/hmr': (path, updatedFleck) => { + * Invoked when a fleck is HMR'd + * @param {string} path The path of the fleck + * @param {Module} updatedFleck The updated fleck module. + */ + '@flecks/core.hmr': (path, updatedFleck) => { if ('my-fleck' === path) { updatedFleck.doSomething(); } }, + /** + * Invoked when a gathered class is HMR'd. + * @param {constructor} Class The class. + * @param {string} hook The gather hook; e.g. `@flecks/db/server.models`. + */ + '@flecks/core.hmr.gathered': (Class, hook) => { + // Do something with Class... + }, + /** * Invoked when the application is starting. Use for order-independent initialization tasks. */ - '@flecks/core/starting': (flecks) => { + '@flecks/core.starting': (flecks) => { flecks.set('$my-fleck/value', initializeMyValue()); }, /** * Define neutrino build targets. */ - '@flecks/core/targets': () => ['sometarget'], + '@flecks/core.targets': () => ['sometarget'], /** * Hook into webpack configuration. * @param {string} target The build target; e.g. `server`. * @param {Object} config The neutrino configuration. */ - '@flecks/core/webpack': (target, config) => { + '@flecks/core.webpack': (target, config) => { if ('something' === target) { config.stats = 'verbose'; } diff --git a/packages/core/src/bootstrap/fleck.neutrinorc.js b/packages/core/src/bootstrap/fleck.neutrinorc.js index bc1853c..69765b2 100644 --- a/packages/core/src/bootstrap/fleck.neutrinorc.js +++ b/packages/core/src/bootstrap/fleck.neutrinorc.js @@ -29,7 +29,7 @@ module.exports = { }, }, ], - pluginId: '@flecks/core/copy', + pluginId: '@flecks/core.copy', }), autoentry(), fleck(), diff --git a/packages/core/src/build/eslintrc.js b/packages/core/src/build/eslintrc.js index 8c9c294..b220382 100644 --- a/packages/core/src/build/eslintrc.js +++ b/packages/core/src/build/eslintrc.js @@ -16,5 +16,5 @@ const flecks = Flecks.bootstrap(); debug('bootstrapped'); const config = R(process.env[targetNeutrino(FLECKS_CORE_BUILD_TARGET)]); -flecks.invokeFlat('@flecks/core/build', FLECKS_CORE_BUILD_TARGET, config); +flecks.invokeFlat('@flecks/core.build', FLECKS_CORE_BUILD_TARGET, config); module.exports = neutrino(config).eslintrc(); diff --git a/packages/core/src/build/webpack.config.js b/packages/core/src/build/webpack.config.js index cd06578..d0b320f 100644 --- a/packages/core/src/build/webpack.config.js +++ b/packages/core/src/build/webpack.config.js @@ -35,7 +35,7 @@ export default (async () => { debug('bootstrapped'); debug('gathering configs'); - let targets = flatten(flecks.invokeFlat('@flecks/core/targets')); + let targets = flatten(flecks.invokeFlat('@flecks/core.targets')); if (buildList.length > 0) { targets = intersection(targets, buildList); } @@ -52,16 +52,16 @@ export default (async () => { )); await Promise.all( entries.map(async ([target, config]) => ( - flecks.invokeFlat('@flecks/core/build', target, config) + flecks.invokeFlat('@flecks/core.build', target, config) )), ); const neutrinoConfigs = Object.fromEntries(entries); - await Promise.all(flecks.invokeFlat('@flecks/core/build/alter', neutrinoConfigs)); + await Promise.all(flecks.invokeFlat('@flecks/core.build.alter', neutrinoConfigs)); const webpackConfigs = await Promise.all( Object.entries(neutrinoConfigs) .map(async ([target, config]) => { const webpackConfig = neutrino(config).webpack(); - await flecks.invokeFlat('@flecks/core/webpack', target, webpackConfig); + await flecks.invokeFlat('@flecks/core.webpack', target, webpackConfig); return webpackConfig; }), ); diff --git a/packages/core/src/cli.js b/packages/core/src/cli.js index d3a3f92..1f598df 100755 --- a/packages/core/src/cli.js +++ b/packages/core/src/cli.js @@ -87,7 +87,7 @@ else { const flecks = Flecks.bootstrap(); debug('bootstrapped'); // Register commands. - const commands = flecks.invokeMerge('@flecks/core/commands', program); + const commands = flecks.invokeMerge('@flecks/core.commands', program); const keys = Object.keys(commands).sort(); for (let i = 0; i < keys.length; ++i) { const { diff --git a/packages/core/src/flecks.js b/packages/core/src/flecks.js index 17cea8b..4cafd23 100644 --- a/packages/core/src/flecks.js +++ b/packages/core/src/flecks.js @@ -15,9 +15,9 @@ import Middleware from './middleware'; const debug = D('@flecks/core/flecks'); -export const ById = Symbol.for('@flecks/core/byId'); -export const ByType = Symbol.for('@flecks/core/byType'); -export const Hooks = Symbol.for('@flecks/core/hooks'); +export const ById = Symbol.for('@flecks/core.byId'); +export const ByType = Symbol.for('@flecks/core.byType'); +export const Hooks = Symbol.for('@flecks/core.hooks'); const capitalize = (string) => string.substring(0, 1).toUpperCase() + string.substring(1); @@ -67,13 +67,13 @@ export default class Flecks { configureFleck(fleck) { this.config[fleck] = { - ...this.invokeFleck('@flecks/core/config', fleck), + ...this.invokeFleck('@flecks/core.config', fleck), ...this.config[fleck], }; } configureFlecks() { - const defaultConfig = this.invoke('@flecks/core/config'); + const defaultConfig = this.invoke('@flecks/core.config'); const flecks = Object.keys(defaultConfig); for (let i = 0; i < flecks.length; i++) { this.configureFleck(flecks[i]); @@ -330,9 +330,11 @@ export default class Flecks { } lookupFlecks(hook) { - const parts = hook.split('/'); - const key = parts.pop(); - return this.config[parts.join('/')]?.[key]?.concat() || []; + const index = hook.indexOf('.'); + if (-1 === index) { + return ['...']; + } + return this.get([hook.slice(0, index), hook.slice(index + 1)], ['...']); } makeMiddleware(hook) { @@ -448,7 +450,7 @@ export default class Flecks { } async up(hook) { - await Promise.all(this.invokeFlat('@flecks/core/starting')); + await Promise.all(this.invokeFlat('@flecks/core.starting')); await this.invokeSequentialAsync(hook); } @@ -474,7 +476,7 @@ export default class Flecks { const Subclass = wrapperClass(Class, id, idAttribute, type, typeAttribute); // eslint-disable-next-line no-multi-assign gathered[type] = gathered[id] = gathered[ById][id] = gathered[ByType][type] = Subclass; - this.invoke('@flecks/core/gathered/hmr', Subclass, hook); + this.invoke('@flecks/core.hmr.gathered', Subclass, hook); } } } diff --git a/packages/core/src/index.js b/packages/core/src/index.js index 82e6f05..178926e 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -17,7 +17,7 @@ export { export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ 'eslint.exclude': [], id: 'flecks', }), diff --git a/packages/core/src/server/commands.js b/packages/core/src/server/commands.js index d5714ad..4db0e00 100644 --- a/packages/core/src/server/commands.js +++ b/packages/core/src/server/commands.js @@ -44,7 +44,7 @@ export const targetNeutrino = (target) => ( ); export const targetNeutrinos = (flecks) => { - const entries = Object.entries(flecks.invoke('@flecks/core/targets')); + const entries = Object.entries(flecks.invoke('@flecks/core.targets')); const targetNeutrinos = {}; for (let i = 0; i < entries.length; ++i) { const [fleck, targets] = entries[i]; @@ -86,7 +86,7 @@ export default (program, flecks) => { ], }, }; - const targets = flatten(flecks.invokeFlat('@flecks/core/targets')); + const targets = flatten(flecks.invokeFlat('@flecks/core.targets')); if (targets.length > 0) { commands.build = { args: [ diff --git a/packages/core/src/server/index.js b/packages/core/src/server/index.js index 1970dda..5758e2b 100644 --- a/packages/core/src/server/index.js +++ b/packages/core/src/server/index.js @@ -18,7 +18,7 @@ export {JsonStream, transform} from './stream'; export default { [Hooks]: { - '@flecks/core/build': (target, config, flecks) => { + '@flecks/core.build': (target, config, flecks) => { const {'eslint.exclude': exclude} = flecks.get('@flecks/core'); if (-1 !== exclude.indexOf(target)) { return; @@ -43,6 +43,6 @@ export default { }), ); }, - '@flecks/core/commands': commands, + '@flecks/core.commands': commands, }, }; diff --git a/packages/core/test/one/index.js b/packages/core/test/one/index.js index 9277f11..c8c3840 100644 --- a/packages/core/test/one/index.js +++ b/packages/core/test/one/index.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line import/no-unresolved +// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved import {Flecks, Hooks} from '@flecks/core'; export const testNodespace = () => [ @@ -10,9 +10,8 @@ export const testNodespace = () => [ export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ foo: 'bar', - 'test-gather.decorate': ['...'], }), '@flecks/core/one/test-gather': ( Flecks.provide(require.context('./things', false, /\.js$/)) diff --git a/packages/core/test/two/index.js b/packages/core/test/two/index.js index 9365fb1..d3f28f4 100644 --- a/packages/core/test/two/index.js +++ b/packages/core/test/two/index.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line import/no-unresolved +// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved import {Flecks, Hooks} from '@flecks/core'; export default { diff --git a/packages/db/build/dox/hooks.js b/packages/db/build/dox/hooks.js index 761d567..b395991 100644 --- a/packages/db/build/dox/hooks.js +++ b/packages/db/build/dox/hooks.js @@ -9,7 +9,7 @@ export default { * defined in its own file. * See: https://github.com/cha0s/flecks/tree/master/packages/user/src/server/models */ - '@flecks/db/server/models': Flecks.provide(require.context('./models', false, /\.js$/)), + '@flecks/db/server.models': Flecks.provide(require.context('./models', false, /\.js$/)), /** * Decorate database models. @@ -20,7 +20,7 @@ export default { * * @param {constructor} Model The model to decorate. */ - '@flecks/db/server/models.decorate': ( + '@flecks/db/server.models.decorate': ( Flecks.decorate(require.context('./models/decorators', false, /\.js$/)) ), }, diff --git a/packages/db/src/server.js b/packages/db/src/server.js index 1079786..7ff9c09 100644 --- a/packages/db/src/server.js +++ b/packages/db/src/server.js @@ -11,26 +11,25 @@ export {createDatabaseConnection}; export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ database: ':memory:', dialect: 'sqlite', host: undefined, - 'models.decorate': ['...'], password: undefined, port: undefined, username: undefined, }), - '@flecks/core/starting': (flecks) => { + '@flecks/core.starting': (flecks) => { flecks.set('$flecks/db.models', flecks.gather( - '@flecks/db/server/models', + '@flecks/db/server.models', {typeAttribute: 'name'}, )); }, - '@flecks/docker/containers': containers, - '@flecks/server/up': async (flecks) => { + '@flecks/docker.containers': containers, + '@flecks/server.up': async (flecks) => { flecks.set('$flecks/db/sequelize', await createDatabaseConnection(flecks)); }, - '@flecks/repl/context': (flecks) => ({ + '@flecks/repl.context': (flecks) => ({ Models: flecks.get('$flecks/db.models'), sequelize: flecks.get('$flecks/db/sequelize'), }), diff --git a/packages/docker/build/dox/hooks.js b/packages/docker/build/dox/hooks.js index af32f8a..1acbb32 100644 --- a/packages/docker/build/dox/hooks.js +++ b/packages/docker/build/dox/hooks.js @@ -8,7 +8,7 @@ export default { * Beware: the user running the server must have Docker privileges. * See: https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user */ - '@flecks/docker/containers': () => ({ + '@flecks/docker.containers': () => ({ someContainer: { // Environment variables. environment: { diff --git a/packages/docker/src/commands.js b/packages/docker/src/commands.js index 83192ad..27d585e 100644 --- a/packages/docker/src/commands.js +++ b/packages/docker/src/commands.js @@ -47,7 +47,7 @@ export default (program, flecks) => { ], }, }; - const containers = flecks.invoke('@flecks/docker/containers'); + const containers = flecks.invoke('@flecks/docker.containers'); ( await Promise.all( Object.entries(containers) diff --git a/packages/docker/src/server.js b/packages/docker/src/server.js index aaca100..b8bf429 100644 --- a/packages/docker/src/server.js +++ b/packages/docker/src/server.js @@ -5,15 +5,15 @@ import startContainer from './start-container'; export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ enabled: true, }), - '@flecks/core/commands': commands, - '@flecks/server/up': async (flecks) => { + '@flecks/core.commands': commands, + '@flecks/server.up': async (flecks) => { if (!flecks.get('@flecks/docker/server.enabled')) { return; } - const containers = await flecks.invokeMergeAsync('@flecks/docker/containers'); + const containers = await flecks.invokeMergeAsync('@flecks/docker.containers'); await Promise.all( Object.entries(containers) .map(([key, config]) => startContainer(flecks, key, config)), diff --git a/packages/dox/src/parser.js b/packages/dox/src/parser.js index 8fa12dc..514da24 100644 --- a/packages/dox/src/parser.js +++ b/packages/dox/src/parser.js @@ -82,7 +82,7 @@ const FlecksInvocations = (state, filename) => ({ path.node.loc, ); state.addInvocation( - '@flecks/core/starting', + '@flecks/core.starting', 'invokeFlat', filename, path.node.loc, diff --git a/packages/dox/src/server.js b/packages/dox/src/server.js index 5033197..aa24671 100644 --- a/packages/dox/src/server.js +++ b/packages/dox/src/server.js @@ -4,8 +4,8 @@ import commands from './commands'; export default { [Hooks]: { - '@flecks/core/commands': commands, - '@flecks/core/config': () => ({ + '@flecks/core.commands': commands, + '@flecks/core.config': () => ({ filenameRewriters: {}, }), }, diff --git a/packages/fleck/src/server/build/fleck.neutrinorc.js b/packages/fleck/src/server/build/fleck.neutrinorc.js index a97c1a7..3c94d15 100644 --- a/packages/fleck/src/server/build/fleck.neutrinorc.js +++ b/packages/fleck/src/server/build/fleck.neutrinorc.js @@ -20,7 +20,7 @@ module.exports = (async () => { debug('bootstrapped'); const compiler = flecks.invokeFleck( - '@flecks/fleck/compiler', + '@flecks/fleck.compiler', flecks.get('@flecks/fleck.compiler'), ); if (compiler) { diff --git a/packages/fleck/src/server/commands.js b/packages/fleck/src/server/commands.js index 96c7663..53ceb70 100644 --- a/packages/fleck/src/server/commands.js +++ b/packages/fleck/src/server/commands.js @@ -10,7 +10,7 @@ import { spawnWith, } from '@flecks/core/server'; -const debug = D('@flecks/core/commands'); +const debug = D('@flecks/core.commands'); const { FLECKS_CORE_ROOT = process.cwd(), diff --git a/packages/fleck/src/server/index.js b/packages/fleck/src/server/index.js index 740d877..966d711 100644 --- a/packages/fleck/src/server/index.js +++ b/packages/fleck/src/server/index.js @@ -4,7 +4,7 @@ import commands from './commands'; export default { [Hooks]: { - '@flecks/core/commands': commands, - '@flecks/core/targets': () => ['fleck'], + '@flecks/core.commands': commands, + '@flecks/core.targets': () => ['fleck'], }, }; diff --git a/packages/governor/src/server.js b/packages/governor/src/server.js index 32399ca..447ee0a 100644 --- a/packages/governor/src/server.js +++ b/packages/governor/src/server.js @@ -7,7 +7,7 @@ export {default as createLimiter} from './limiter'; export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ keys: ['ip'], http: { keys: ['ip'], @@ -22,8 +22,8 @@ export default { ttl: 30, }, }), - '@flecks/db/server/models': Flecks.provide(require.context('./models', false, /\.js$/)), - '@flecks/http/server/request.route': (flecks) => { + '@flecks/db/server.models': Flecks.provide(require.context('./models', false, /\.js$/)), + '@flecks/http/server.request.route': (flecks) => { const {http} = flecks.get('@flecks/governor/server'); const limiter = flecks.get('$flecks/governor.http.limiter'); return async (req, res, next) => { @@ -52,7 +52,7 @@ export default { } }; }, - '@flecks/server/up': async (flecks) => { + '@flecks/server.up': async (flecks) => { if (flecks.fleck('@flecks/http/server')) { const {http} = flecks.get('@flecks/governor/server'); const limiter = await createLimiter( @@ -93,7 +93,7 @@ export default { flecks.set('$flecks/governor.socket.limiter', limiter); } }, - '@flecks/socket/server/request.socket': (flecks) => { + '@flecks/socket/server.request.socket': (flecks) => { const limiter = flecks.get('$flecks/governor.socket.limiter'); return async (socket, next) => { const {handshake: req} = socket; @@ -120,7 +120,7 @@ export default { } }; }, - '@flecks/socket/packets.decorate': (Packets, flecks) => ( + '@flecks/socket.packets.decorate': (Packets, flecks) => ( Object.fromEntries( Object.entries(Packets).map(([keyPrefix, Packet]) => [ keyPrefix, diff --git a/packages/http/build/dox/hooks.js b/packages/http/build/dox/hooks.js index c0c3193..7235c33 100644 --- a/packages/http/build/dox/hooks.js +++ b/packages/http/build/dox/hooks.js @@ -5,14 +5,14 @@ export default { /** * Define sequential actions to run when the client comes up. */ - '@flecks/http/client/up': async () => { + '@flecks/http/client.up': async () => { await youCanDoAsyncThingsHere(); }, /** * Override flecks configuration sent to client flecks. * @param {http.ClientRequest} req The HTTP request object. */ - '@flecks/http/config': (req) => ({ + '@flecks/http.config': (req) => ({ someClientFleck: { someConfig: req.someConfig, }, @@ -20,7 +20,7 @@ export default { /** * Define HTTP routes. */ - '@flecks/http/routes': () => [ + '@flecks/http.routes': () => [ { method: 'get', path: '/some-path', @@ -33,20 +33,20 @@ export default { /** * Define neutrino compilation middleware (e.g. @neutrinojs/react). */ - '@flecks/http/server/compiler': () => { + '@flecks/http/server.compiler': () => { return require('@neutrinojs/node'); }, /** * Define middleware to run when a route is matched. */ - '@flecks/http/server/request.route': () => (req, res, next) => { + '@flecks/http/server.request.route': () => (req, res, next) => { // Express-style route middleware... next(); }, /** * Define middleware to run when an HTTP socket connection is established. */ - '@flecks/http/server/request.socket': () => (req, res, next) => { + '@flecks/http/server.request.socket': () => (req, res, next) => { // Express-style route middleware... next(); }, @@ -55,13 +55,13 @@ export default { * @param {stream.Readable} stream The HTML stream. * @param {http.ClientRequest} req The HTTP request object. */ - '@flecks/http/server/stream.html': (stream, req) => { + '@flecks/http/server.stream.html': (stream, req) => { return stream.pipe(myTransformStream); }, /** * Define sequential actions to run when the HTTP server comes up. */ - '@flecks/http/server/up': async () => { + '@flecks/http/server.up': async () => { await youCanDoAsyncThingsHere(); }, }, diff --git a/packages/http/package.json b/packages/http/package.json index fb2030e..bcfccea 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -20,8 +20,6 @@ "files": [ "build", "build/template.ejs", - "client.js", - "client.js.map", "client/tests.js", "client/tests.js.map", "entry.js", diff --git a/packages/http/src/client/index.js b/packages/http/src/client/index.js deleted file mode 100644 index 25bb75b..0000000 --- a/packages/http/src/client/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import {Hooks} from '@flecks/core'; - -export default { - [Hooks]: { - '@flecks/core/config': () => ({ - up: ['...'], - }), - }, -}; diff --git a/packages/http/src/entry.js b/packages/http/src/entry.js index 2a126d2..6e884a6 100644 --- a/packages/http/src/entry.js +++ b/packages/http/src/entry.js @@ -11,7 +11,7 @@ const progress = new Progress(window); (async () => { // eslint-disable-next-line no-console console.log(`flecks client v${version} loading runtime...`); - const config = window[Symbol.for('@flecks/http/config')]; + const config = window[Symbol.for('@flecks/http.config')]; const debug = D(config['@flecks/core']?.id || 'flecks'); debug('loading runtime...'); const {default: loader} = await __non_webpack_import__( @@ -24,7 +24,7 @@ const progress = new Progress(window); const flecks = new Flecks(runtime); window.flecks = flecks; try { - await flecks.up('@flecks/http/client/up'); + await flecks.up('@flecks/http/client.up'); debug('up!'); } catch (error) { diff --git a/packages/http/src/server/build/http.neutrinorc.js b/packages/http/src/server/build/http.neutrinorc.js index a0cf5f1..71637ac 100644 --- a/packages/http/src/server/build/http.neutrinorc.js +++ b/packages/http/src/server/build/http.neutrinorc.js @@ -37,7 +37,7 @@ module.exports = (async () => { }; // Compile code. const compiler = flecks.invokeFleck( - '@flecks/http/server/compiler', + '@flecks/http/server.compiler', flecks.get('@flecks/http/server.compiler'), ); if (compiler) { diff --git a/packages/http/src/server/build/runtime.js b/packages/http/src/server/build/runtime.js index 0249c15..d2ec94f 100644 --- a/packages/http/src/server/build/runtime.js +++ b/packages/http/src/server/build/runtime.js @@ -24,7 +24,7 @@ module.exports = async (flecks) => { const paths = Object.entries(resolver); const source = [ 'module.exports = (update) => (async () => ({', - " config: window[Symbol.for('@flecks/http/config')],", + " config: window[Symbol.for('@flecks/http.config')],", ' flecks: Object.fromEntries(await Promise.all([', paths .map(([path]) => [ @@ -45,7 +45,7 @@ module.exports = async (flecks) => { source.push(` module.hot.accept('${path}', async () => {`); source.push(` const updatedFleck = require('${path}');`); source.push(` window.flecks.refresh('${path}', updatedFleck);`); - source.push(` window.flecks.invoke('@flecks/core/hmr', '${path}', updatedFleck);`); + source.push(` window.flecks.invoke('@flecks/core.hmr', '${path}', updatedFleck);`); source.push(' });'); }); source.push('}'); diff --git a/packages/http/src/server/config.js b/packages/http/src/server/config.js index 9b4cabd..2f7e071 100644 --- a/packages/http/src/server/config.js +++ b/packages/http/src/server/config.js @@ -1,7 +1,7 @@ import {Transform} from 'stream'; const config = async (flecks, req) => { - const httpConfig = await flecks.invokeMergeAsync('@flecks/http/config', req); + const httpConfig = await flecks.invokeMergeAsync('@flecks/http.config', req); const config = {}; const {resolver} = flecks.get('$flecks/http.flecks'); const keys = Object.keys(resolver); @@ -24,7 +24,7 @@ const config = async (flecks, req) => { export const configSource = async (flecks, req) => { const codedConfig = encodeURIComponent(JSON.stringify(await config(flecks, req))); - return `window[Symbol.for('@flecks/http/config')] = JSON.parse(decodeURIComponent("${ + return `window[Symbol.for('@flecks/http.config')] = JSON.parse(decodeURIComponent("${ codedConfig }"));`; }; diff --git a/packages/http/src/server/http.js b/packages/http/src/server/http.js index 30afb76..f92887e 100644 --- a/packages/http/src/server/http.js +++ b/packages/http/src/server/http.js @@ -16,7 +16,7 @@ const { const debug = D('@flecks/http/server/http'); const deliverHtmlStream = (stream, flecks, req, res) => { - flecks.invokeComposed('@flecks/http/server/stream.html', stream, req).pipe(res); + flecks.invokeComposed('@flecks/http/server.stream.html', stream, req).pipe(res); }; export const createHttpServer = async (flecks) => { @@ -36,10 +36,10 @@ export const createHttpServer = async (flecks) => { // Compression. heheh app.use(compression({level: 'production' === NODE_ENV ? 6 : 9})); // Socket connection. - app.use(flecks.makeMiddleware('@flecks/http/server/request.socket')); + app.use(flecks.makeMiddleware('@flecks/http/server.request.socket')); // Routes. - const routeMiddleware = flecks.makeMiddleware('@flecks/http/server/request.route'); - const routes = flatten(flecks.invokeFlat('@flecks/http/routes')); + const routeMiddleware = flecks.makeMiddleware('@flecks/http/server.request.route'); + const routes = flatten(flecks.invokeFlat('@flecks/http.routes')); routes.forEach(({method, path, middleware}) => app[method](path, routeMiddleware, middleware)); // In development mode, create a proxy to the webpack-dev-server. if ('production' !== NODE_ENV) { @@ -117,7 +117,7 @@ export const createHttpServer = async (flecks) => { reject(error); return; } - await Promise.all(flecks.invokeFlat('@flecks/http/server/up', httpServer)); + await Promise.all(flecks.invokeFlat('@flecks/http/server.up', httpServer)); debug('HTTP server up @ %s!', [host, port].filter((e) => !!e).join(':')); resolve(); }); diff --git a/packages/http/src/server/index.js b/packages/http/src/server/index.js index e06da61..d3de811 100644 --- a/packages/http/src/server/index.js +++ b/packages/http/src/server/index.js @@ -8,7 +8,7 @@ const debug = D('@flecks/http/server'); export default { [Hooks]: { - '@flecks/core/build/alter': (neutrinoConfigs, flecks) => { + '@flecks/core.build.alter': (neutrinoConfigs, flecks) => { // Bail if there's no http build. if (!neutrinoConfigs.http) { return; @@ -36,7 +36,7 @@ export default { // eslint-disable-next-line no-param-reassign delete neutrinoConfigs.http; }, - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ devHost: 'localhost', devPort: undefined, devPublic: undefined, @@ -44,20 +44,18 @@ export default { host: '0.0.0.0', output: 'http', port: 32340, - 'stream.html': ['...'], 'request.route': [], 'request.socket': [], trust: false, - up: ['...'], }), - '@flecks/core/starting': (flecks) => { + '@flecks/core.starting': (flecks) => { debug('bootstrapping flecks...'); const httpFlecks = Flecks.bootstrap({platforms: ['client'], without: ['server']}); debug('bootstrapped'); flecks.set('$flecks/http.flecks', httpFlecks); }, - '@flecks/core/targets': () => ['http'], - '@flecks/http/routes': (flecks) => [ + '@flecks/core.targets': () => ['http'], + '@flecks/http.routes': (flecks) => [ { method: 'get', path: '/flecks.config.js', @@ -67,9 +65,9 @@ export default { }, }, ], - '@flecks/http/server/stream.html': inlineConfig, - '@flecks/server/up': (flecks) => createHttpServer(flecks), - '@flecks/repl/context': (flecks) => ({ + '@flecks/http/server.stream.html': inlineConfig, + '@flecks/server.up': (flecks) => createHttpServer(flecks), + '@flecks/repl.context': (flecks) => ({ httpServer: flecks.get('$flecks/http/server.instance'), }), }, diff --git a/packages/react/build/dox/hooks.js b/packages/react/build/dox/hooks.js index 6863fa9..7119a80 100644 --- a/packages/react/build/dox/hooks.js +++ b/packages/react/build/dox/hooks.js @@ -8,7 +8,7 @@ export default { * Note: `req` will be only be defined when server-side rendering. * @param {http.ClientRequest} req The HTTP request object. */ - '@flecks/react/providers': (req) => { + '@flecks/react.providers': (req) => { // Generally it makes more sense to separate client and server concerns using platform // naming conventions, but this is just a small contrived example. return req ? serverSideProvider(req) : clientSideProvider(); @@ -18,7 +18,7 @@ export default { * Note: `req` will be only be defined when server-side rendering. * @param {http.ClientRequest} req The HTTP request object. */ - '@flecks/react/roots': (req) => { + '@flecks/react.roots': (req) => { // Note that we're not returning ``, but `Component`. return Component; }, diff --git a/packages/react/src/client.js b/packages/react/src/client.js index a53b9c2..9e06aae 100644 --- a/packages/react/src/client.js +++ b/packages/react/src/client.js @@ -12,7 +12,7 @@ export {FlecksContext}; export default { [Hooks]: { - '@flecks/http/client/up': async (flecks) => { + '@flecks/http/client.up': async (flecks) => { const {ssr} = flecks.get('@flecks/react'); debug('%sing...', ssr ? 'hydrat' : 'render'); (ssr ? hydrate : render)( diff --git a/packages/react/src/hooks/use-flecks.js b/packages/react/src/hooks/use-flecks.js index 83a502a..fd9c09c 100644 --- a/packages/react/src/hooks/use-flecks.js +++ b/packages/react/src/hooks/use-flecks.js @@ -7,10 +7,10 @@ export default () => { const flecks = useContext(FlecksContext); // Hack... force flecks update on HMR. useEffect(() => { - if (!flecks.hooks['@flecks/core/hmr']) { - flecks.hooks['@flecks/core/hmr'] = []; + if (!flecks.hooks['@flecks/core.hmr']) { + flecks.hooks['@flecks/core.hmr'] = []; } - flecks.hooks['@flecks/core/hmr'].push({ + flecks.hooks['@flecks/core.hmr'].push({ plugin: '@flecks/react/hmr', fn: () => { setId(Math.random()); diff --git a/packages/react/src/index.js b/packages/react/src/index.js index 318d150..6eadd39 100644 --- a/packages/react/src/index.js +++ b/packages/react/src/index.js @@ -15,8 +15,7 @@ export {default as usePrevious} from './hooks/use-previous'; export default { [Hooks]: { - '@flecks/core/config': () => ({ - providers: ['...'], + '@flecks/core.config': () => ({ ssr: true, }), }, diff --git a/packages/react/src/root.js b/packages/react/src/root.js index b1436cb..cbfa916 100644 --- a/packages/react/src/root.js +++ b/packages/react/src/root.js @@ -7,9 +7,9 @@ import FlecksContext from '@flecks/react/context'; const debug = D('@flecks/react/root'); export default async (flecks, req) => { - const Roots = flecks.invoke('@flecks/react/roots', req); + const Roots = flecks.invoke('@flecks/react.roots', req); debug('roots: %O', Object.keys(Roots)); - const Providers = await flecks.invokeSequentialAsync('@flecks/react/providers', req); + const Providers = await flecks.invokeSequentialAsync('@flecks/react.providers', req); const FlattenedProviders = []; for (let i = 0; i < Providers.length; i++) { const Provider = Providers[i]; diff --git a/packages/react/src/router/client.js b/packages/react/src/router/client.js index b681c4b..28511c4 100644 --- a/packages/react/src/router/client.js +++ b/packages/react/src/router/client.js @@ -6,7 +6,7 @@ import {HistoryRouter as ReduxHistoryRouter} from 'redux-first-history/rr6'; export default { [Hooks]: { - '@flecks/react/providers': (req, flecks) => ( + '@flecks/react.providers': (req, flecks) => ( flecks.fleck('@flecks/redux') ? [ReduxHistoryRouter, {history: createReduxHistory(flecks.get('$flecks/redux/store'))}] : [HistoryRouter, {history}] diff --git a/packages/react/src/router/index.js b/packages/react/src/router/index.js index d7ff1a5..591c801 100644 --- a/packages/react/src/router/index.js +++ b/packages/react/src/router/index.js @@ -7,10 +7,10 @@ export * from 'redux-first-history'; export default { [Hooks]: { - '@flecks/redux/slices': () => ({ + '@flecks/redux.slices': () => ({ router: routerReducer, }), - '@flecks/redux/store': (options) => { + '@flecks/redux.store': (options) => { options.middleware.push(routerMiddleware); }, }, diff --git a/packages/react/src/router/server.js b/packages/react/src/router/server.js index fe29b6b..b393727 100644 --- a/packages/react/src/router/server.js +++ b/packages/react/src/router/server.js @@ -3,7 +3,7 @@ import {StaticRouter} from 'react-router-dom/server'; export default { [Hooks]: { - '@flecks/react/providers': (req, flecks) => ( + '@flecks/react.providers': (req, flecks) => ( flecks.get('@flecks/react.ssr') ? [StaticRouter, {location: req.url}] : [] ), }, diff --git a/packages/react/src/server.js b/packages/react/src/server.js index 915a878..9c173b8 100644 --- a/packages/react/src/server.js +++ b/packages/react/src/server.js @@ -5,7 +5,7 @@ import ssr from './ssr'; export default { [Hooks]: { - '@flecks/http/server/compiler': (flecks) => ( + '@flecks/http/server.compiler': (flecks) => ( react({ clean: false, hot: false, @@ -23,7 +23,7 @@ export default { }, }) ), - '@flecks/http/server/stream.html': (stream, req, flecks) => ( + '@flecks/http/server.stream.html': (stream, req, flecks) => ( flecks.get('@flecks/react.ssr') ? ssr(stream, req, flecks) : stream ), }, diff --git a/packages/redis/src/server.js b/packages/redis/src/server.js index 5f9c3bf..6749956 100644 --- a/packages/redis/src/server.js +++ b/packages/redis/src/server.js @@ -29,12 +29,12 @@ export const keys = (client, pattern) => safeKeys(client, pattern, 0); export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ host: 'localhost', port: 6379, }), - '@flecks/docker/containers': containers, - '@flecks/repl/context': (flecks) => ({ + '@flecks/docker.containers': containers, + '@flecks/repl.context': (flecks) => ({ redisClient: createClient(flecks), }), }, diff --git a/packages/redis/src/session/server.js b/packages/redis/src/session/server.js index f5a7e7a..9347184 100644 --- a/packages/redis/src/session/server.js +++ b/packages/redis/src/session/server.js @@ -11,14 +11,14 @@ const RedisStore = ConnectRedis(session); export default { [Hooks]: { - '@flecks/user/session': async (flecks) => { + '@flecks/user.session': async (flecks) => { const client = createClient(flecks, {legacyMode: true}); await client.connect(); return { store: new RedisStore({client}), }; }, - '@flecks/socket/server': async (flecks) => { + '@flecks/socket.server': async (flecks) => { const pubClient = createClient(flecks); const subClient = createClient(flecks); await Promise.all([pubClient.connect(), subClient.connect()]); diff --git a/packages/redux/build/dox/hooks.js b/packages/redux/build/dox/hooks.js index a888410..7fe2f32 100644 --- a/packages/redux/build/dox/hooks.js +++ b/packages/redux/build/dox/hooks.js @@ -5,7 +5,7 @@ export default { /** * Define side-effects to run against Redux actions. */ - '@flecks/redux/effects': () => ({ + '@flecks/redux.effects': () => ({ someActionName: (store, action, flecks) => { // Runs when `someActionName` actions are dispatched. }, @@ -13,7 +13,7 @@ export default { /** * Define root-level reducers for the Redux store. */ - '@flecks/redux/reducers': () => { + '@flecks/redux.reducers': () => { return (state, action) => { // Whatever you'd like. return state; @@ -24,7 +24,7 @@ export default { * * See: https://redux-toolkit.js.org/api/createSlice */ - '@flecks/redux/slices': () => { + '@flecks/redux.slices': () => { const something = createSlice( // ... ); @@ -36,7 +36,7 @@ export default { * Modify Redux store configuration. * @param {Object} options A mutable object with keys for enhancers and middleware. */ - '@flecks/redux/store': (options) => { + '@flecks/redux.store': (options) => { options.enhancers.splice(someIndex, 1); options.middleware.push(mySpecialMiddleware); }, diff --git a/packages/redux/src/actions.js b/packages/redux/src/actions.js index feaaa28..7d989a6 100644 --- a/packages/redux/src/actions.js +++ b/packages/redux/src/actions.js @@ -4,4 +4,4 @@ export const hydrateServer = createAction('@flecks/redux/hydrate.server'); export const hydrateLocalStorage = createAction('@flecks/redux/hydrate.localStorage'); -export const storeLocalStorage = createAction('@flecks/redux/store.localStorage'); +export const storeLocalStorage = createAction('@flecks/redux.store.localStorage'); diff --git a/packages/redux/src/client/index.js b/packages/redux/src/client/index.js index d33ac87..1c4ce19 100644 --- a/packages/redux/src/client/index.js +++ b/packages/redux/src/client/index.js @@ -6,8 +6,8 @@ import localStorageEnhancer from './local-storage'; export default { [Hooks]: { - '@flecks/react/providers': async (req, flecks) => { - const slices = await ensureUniqueReduction(flecks, '@flecks/redux/slices'); + '@flecks/react.providers': async (req, flecks) => { + const slices = await ensureUniqueReduction(flecks, '@flecks/redux.slices'); const reducer = createReducer(flecks, slices); // Hydrate from server. const {preloadedState} = flecks.get('@flecks/redux/client'); @@ -15,11 +15,11 @@ export default { flecks.set('$flecks/redux/store', store); return [Provider, {store}]; }, - '@flecks/redux/store': ({enhancers}) => { + '@flecks/redux.store': ({enhancers}) => { // Hydrate from and subscribe to localStorage. enhancers.push(localStorageEnhancer); }, - '@flecks/socket/packets.decorate': ( + '@flecks/socket.packets.decorate': ( Flecks.decorate(require.context('./packets/decorators', false, /\.js$/)) ), }, diff --git a/packages/redux/src/index.js b/packages/redux/src/index.js index 3a582ab..1e5ff24 100644 --- a/packages/redux/src/index.js +++ b/packages/redux/src/index.js @@ -7,6 +7,6 @@ export * from './actions'; export default { [Hooks]: { - '@flecks/socket/packets': Flecks.provide(require.context('./packets', false, /\.js$/)), + '@flecks/socket.packets': Flecks.provide(require.context('./packets', false, /\.js$/)), }, }; diff --git a/packages/redux/src/server.js b/packages/redux/src/server.js index ddfee16..07b6b13 100644 --- a/packages/redux/src/server.js +++ b/packages/redux/src/server.js @@ -9,8 +9,8 @@ const debug = D('@flecks/redux/server'); export default { [Hooks]: { - '@flecks/http/server/request.route': (flecks) => async (req, res, next) => { - const slices = await ensureUniqueReduction(flecks, '@flecks/redux/slices'); + '@flecks/http/server.request.route': (flecks) => async (req, res, next) => { + const slices = await ensureUniqueReduction(flecks, '@flecks/redux.slices'); const reducer = createReducer(flecks, slices); const preloadedState = reducer(undefined, hydrateServer({flecks, req})); debug( @@ -21,11 +21,11 @@ export default { req.redux = await configureStore(flecks, reducer, {preloadedState}); next(); }, - '@flecks/http/config': async (req) => ({ + '@flecks/http.config': async (req) => ({ '@flecks/redux/client': { preloadedState: req.redux.getState(), }, }), - '@flecks/react/providers': (req) => [Provider, {store: req.redux}], + '@flecks/react.providers': (req) => [Provider, {store: req.redux}], }, }; diff --git a/packages/redux/src/store/create-reducer.js b/packages/redux/src/store/create-reducer.js index fd4c2bf..922f263 100644 --- a/packages/redux/src/store/create-reducer.js +++ b/packages/redux/src/store/create-reducer.js @@ -2,7 +2,7 @@ import {combineReducers} from '@reduxjs/toolkit'; import reduceReducers from 'reduce-reducers'; export default (flecks, slices) => { - let reducers = flecks.invokeFlat('@flecks/redux/reducers'); + let reducers = flecks.invokeFlat('@flecks/redux.reducers'); if (Object.keys(slices).length > 0) { reducers = reducers.concat(combineReducers(slices)); } diff --git a/packages/redux/src/store/index.js b/packages/redux/src/store/index.js index 6780e01..c4c3c25 100644 --- a/packages/redux/src/store/index.js +++ b/packages/redux/src/store/index.js @@ -14,7 +14,7 @@ export default async function configureStore(flecks, reducer, {preloadedState}) effectsMiddleware(flecks), ], }; - flecks.invokeFlat('@flecks/redux/store', options); + flecks.invokeFlat('@flecks/redux.store', options); return configureStoreR({ enhancers: (defaultEnhancers) => { const index = options.enhancers.indexOf('@flecks/redux/defaultEnhancers'); diff --git a/packages/redux/src/store/middleware/effects.js b/packages/redux/src/store/middleware/effects.js index 958cf40..42898ac 100644 --- a/packages/redux/src/store/middleware/effects.js +++ b/packages/redux/src/store/middleware/effects.js @@ -1,5 +1,5 @@ export default (flecks) => { - const effects = flecks.invokeFlat('@flecks/redux/effects'); + const effects = flecks.invokeFlat('@flecks/redux.effects'); const effect = (store, action) => { effects.forEach((map) => { if (map[action.type]) { diff --git a/packages/repl/build/dox/hooks.js b/packages/repl/build/dox/hooks.js index 3780cb2..fdd351f 100644 --- a/packages/repl/build/dox/hooks.js +++ b/packages/repl/build/dox/hooks.js @@ -7,7 +7,7 @@ export default { * * Note: commands will be prefixed with a period in the Node REPL. */ - '@flecks/repl/commands': () => ({ + '@flecks/repl.commands': () => ({ someCommand: (...args) => { // args are passed from the Node REPL. So, you could invoke it like: // .someCommand foo bar @@ -17,7 +17,7 @@ export default { /** * Provide global context to the REPL. */ - '@flecks/repl/context': () => { + '@flecks/repl.context': () => { // Now you'd be able to do like: // `node> someValue;` // and the REPL would evaluate it to `'foobar'`. diff --git a/packages/repl/src/repl.js b/packages/repl/src/repl.js index 21684f4..c303612 100644 --- a/packages/repl/src/repl.js +++ b/packages/repl/src/repl.js @@ -10,7 +10,7 @@ const debug = D('@flecks/repl'); export async function createReplServer(flecks) { const {id} = flecks.get('@flecks/core'); - const context = flecks.invokeFlat('@flecks/repl/context') + const context = flecks.invokeFlat('@flecks/repl.context') .reduce((r, vars) => ({...r, ...vars}), {flecks}); debug( 'context = %O', @@ -18,7 +18,7 @@ export async function createReplServer(flecks) { ); const commands = {}; Object.entries( - flecks.invokeFlat('@flecks/repl/commands').reduce((r, commands) => ({...r, ...commands}), {}), + flecks.invokeFlat('@flecks/repl.commands').reduce((r, commands) => ({...r, ...commands}), {}), ).forEach(([key, value]) => { commands[key] = value; debug('registered command: %s', key); diff --git a/packages/repl/src/server.js b/packages/repl/src/server.js index 17bd174..74a2f5b 100644 --- a/packages/repl/src/server.js +++ b/packages/repl/src/server.js @@ -5,7 +5,7 @@ import {createReplServer} from './repl'; export default { [Hooks]: { - '@flecks/core/commands': commands, - '@flecks/server/up': (flecks) => createReplServer(flecks), + '@flecks/core.commands': commands, + '@flecks/server.up': (flecks) => createReplServer(flecks), }, }; diff --git a/packages/server/build/dox/hooks.js b/packages/server/build/dox/hooks.js index e32e4fb..534660d 100644 --- a/packages/server/build/dox/hooks.js +++ b/packages/server/build/dox/hooks.js @@ -5,13 +5,13 @@ export default { /** * Define neutrino compilation middleware (e.g. @neutrinojs/react). */ - '@flecks/server/compiler': () => { + '@flecks/server.compiler': () => { return require('@neutrinojs/node'); }, /** * Define sequential actions to run when the server comes up. */ - '@flecks/server/up': async () => { + '@flecks/server.up': async () => { await youCanDoAsyncThingsHere(); }, }, diff --git a/packages/server/src/entry.js b/packages/server/src/entry.js index e8935e1..e034a00 100644 --- a/packages/server/src/entry.js +++ b/packages/server/src/entry.js @@ -24,7 +24,7 @@ const {version} = require('../package.json'); const flecks = new Flecks(runtime); global.flecks = flecks; try { - await flecks.up('@flecks/server/up'); + await flecks.up('@flecks/server.up'); debug('up!'); } catch (error) { diff --git a/packages/server/src/index.js b/packages/server/src/index.js index 990db1a..ff40697 100644 --- a/packages/server/src/index.js +++ b/packages/server/src/index.js @@ -2,12 +2,11 @@ import {Hooks} from '@flecks/core'; export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ hot: false, inspect: false, profile: false, start: false, - up: ['...'], }), }, }; diff --git a/packages/server/src/server/build/runtime.js b/packages/server/src/server/build/runtime.js index 2f95ae6..69f120e 100644 --- a/packages/server/src/server/build/runtime.js +++ b/packages/server/src/server/build/runtime.js @@ -44,7 +44,7 @@ module.exports = async (flecks) => { paths.forEach((path) => { source.push(` module.hot.accept('${path}', async () => {`); source.push(` global.flecks.refresh('${path}', require('${path}'));`); - source.push(` global.flecks.invoke('@flecks/core/hmr', '${path}');`); + source.push(` global.flecks.invoke('@flecks/core.hmr', '${path}');`); source.push(' });'); }); source.push('}'); diff --git a/packages/server/src/server/build/server.neutrinorc.js b/packages/server/src/server/build/server.neutrinorc.js index 403f73d..c5727a6 100644 --- a/packages/server/src/server/build/server.neutrinorc.js +++ b/packages/server/src/server/build/server.neutrinorc.js @@ -64,7 +64,7 @@ module.exports = (async () => { }; const compiler = flecks.invokeFleck( - '@flecks/server/compiler', + '@flecks/server.compiler', flecks.get('@flecks/server.compiler'), ); diff --git a/packages/server/src/server/index.js b/packages/server/src/server/index.js index fe24d7c..0ad1557 100644 --- a/packages/server/src/server/index.js +++ b/packages/server/src/server/index.js @@ -2,6 +2,6 @@ import {Hooks} from '@flecks/core'; export default { [Hooks]: { - '@flecks/core/targets': () => ['server'], + '@flecks/core.targets': () => ['server'], }, }; diff --git a/packages/socket/build/dox/hooks.js b/packages/socket/build/dox/hooks.js index 95b92bd..482336d 100644 --- a/packages/socket/build/dox/hooks.js +++ b/packages/socket/build/dox/hooks.js @@ -7,13 +7,13 @@ export default { * * See: https://socket.io/docs/v4/client-options/ */ - '@flecks/socket/client': () => ({ + '@flecks/socket.client': () => ({ timeout: Infinity, }), /** * Define server-side intercom channels. */ - '@flecks/socket/intercom': (req) => ({ + '@flecks/socket.intercom': (req) => ({ // This would have been called like: // `const result = await req.intercom('someChannel', payload)`. // `result` will be an `n`-length array, where `n` is the number of server instances. Each @@ -33,7 +33,7 @@ export default { * See: https://github.com/cha0s/flecks/tree/master/packages/socket/src/packet/packet.js * See: https://github.com/cha0s/flecks/tree/master/packages/socket/src/packet/redirect.js */ - '@flecks/socket/packets': Flecks.provide(require.context('./packets', false, /\.js$/)), + '@flecks/socket.packets': Flecks.provide(require.context('./packets', false, /\.js$/)), /** * Decorate database models. * @@ -41,7 +41,7 @@ export default { * decorator would be defined in its own file. * @param {constructor} Packet The packet to decorate. */ - '@flecks/socket/packets.decorate': ( + '@flecks/socket.packets.decorate': ( Flecks.decorate(require.context('./packets/decorators', false, /\.js$/)) ), @@ -50,13 +50,13 @@ export default { * * See: https://socket.io/docs/v4/server-options/ */ - '@flecks/socket/server': () => ({ + '@flecks/socket.server': () => ({ pingTimeout: Infinity, }), /** * Define middleware to run when a socket connection is established. */ - '@flecks/socket/server/request.socket': () => (socket, next) => { + '@flecks/socket/server.request.socket': () => (socket, next) => { // Express-style route middleware... next(); }, diff --git a/packages/socket/src/client/index.js b/packages/socket/src/client/index.js index 6cb151c..2b3d35d 100644 --- a/packages/socket/src/client/index.js +++ b/packages/socket/src/client/index.js @@ -4,13 +4,13 @@ import SocketClient from './socket'; export default { [Hooks]: { - '@flecks/http/client/up': (flecks) => { + '@flecks/http/client.up': (flecks) => { const socket = new SocketClient(flecks); flecks.set('$flecks/socket.socket', socket); socket.connect(); socket.listen(); }, - '@flecks/socket/client': ({config: {'@flecks/core': {id}}}) => ({ + '@flecks/socket.client': ({config: {'@flecks/core': {id}}}) => ({ cors: { origin: false, }, diff --git a/packages/socket/src/client/socket.js b/packages/socket/src/client/socket.js index 51189b8..c1f53d9 100644 --- a/packages/socket/src/client/socket.js +++ b/packages/socket/src/client/socket.js @@ -30,7 +30,7 @@ export default class SocketClient extends decorate(Socket) { { reconnectionDelay: 'production' === process.env.NODE_ENV ? 1000 : 100, reconnectionDelayMax: 'production' === process.env.NODE_ENV ? 5000 : 500, - ...this.flecks.invokeMerge('@flecks/socket/client'), + ...this.flecks.invokeMerge('@flecks/socket.client'), }, ); this.socket.emitPromise = promisify(this.socket.emit.bind(this.socket)); diff --git a/packages/socket/src/index.js b/packages/socket/src/index.js index 86037a8..db45e76 100644 --- a/packages/socket/src/index.js +++ b/packages/socket/src/index.js @@ -10,16 +10,13 @@ export {default as Packet, Packer, ValidationError} from './packet'; export default { [Hooks]: { - '@flecks/core/config': () => ({ - 'packets.decorate': ['...'], - }), - '@flecks/core/starting': (flecks) => { + '@flecks/core.starting': (flecks) => { flecks.set('$flecks/socket.packets', flecks.gather( - '@flecks/socket/packets', + '@flecks/socket.packets', {check: badPacketsCheck}, )); }, - '@flecks/http/config': async ( + '@flecks/http.config': async ( req, {config: {'@flecks/socket': {'packets.decorate': decorators}}}, ) => ({ @@ -29,7 +26,7 @@ export default { ), }, }), - '@flecks/socket/packets': (flecks) => ({ + '@flecks/socket.packets': (flecks) => ({ Bundle: Bundle(flecks), Redirect, Refresh, diff --git a/packages/socket/src/server/create-intercom.js b/packages/socket/src/server/create-intercom.js index bbbcc8d..6dfe18e 100644 --- a/packages/socket/src/server/create-intercom.js +++ b/packages/socket/src/server/create-intercom.js @@ -7,7 +7,7 @@ export default function createIntercom(sockets, transport) { debug('@flecks/socket.s: %s(%o)', transport, type, payload); const responses = await new Promise((resolve, reject) => { sockets.io.serverSideEmit( - '@flecks/socket/intercom', + '@flecks/socket.intercom', {payload, type}, (error, responses) => (error ? reject(error) : resolve(responses)), ); diff --git a/packages/socket/src/server/index.js b/packages/socket/src/server/index.js index 612d587..90f5ba1 100644 --- a/packages/socket/src/server/index.js +++ b/packages/socket/src/server/index.js @@ -5,24 +5,24 @@ import Sockets from './sockets'; export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ connect: [], 'request.socket': [], }), - '@flecks/http/server/request.socket': ({config: {'$flecks/socket.sockets': sockets}}) => (req, res, next) => { + '@flecks/http/server.request.socket': ({config: {'$flecks/socket.sockets': sockets}}) => (req, res, next) => { req.intercom = createIntercom(sockets, 'http'); next(); }, - '@flecks/http/server/up': async (httpServer, flecks) => { + '@flecks/http/server.up': async (httpServer, flecks) => { const sockets = new Sockets(httpServer, flecks); await sockets.connect(); flecks.set('$flecks/socket.sockets', sockets); }, - '@flecks/repl/context': (flecks) => ({ + '@flecks/repl.context': (flecks) => ({ Packets: flecks.get('$flecks/socket.packets'), sockets: flecks.get('$flecks/socket.sockets'), }), - '@flecks/socket/server': ({config: {'@flecks/core': {id}}}) => ({ + '@flecks/socket.server': ({config: {'@flecks/core': {id}}}) => ({ path: `/${id}/socket.io`, }), }, diff --git a/packages/socket/src/server/sockets.js b/packages/socket/src/server/sockets.js index 0a09367..35ffe0a 100644 --- a/packages/socket/src/server/sockets.js +++ b/packages/socket/src/server/sockets.js @@ -14,7 +14,7 @@ export default class SocketServer { this.onConnect = this.onConnect.bind(this); this.flecks = flecks; this.httpServer = httpServer; - const hooks = flecks.invokeMerge('@flecks/socket/intercom'); + const hooks = flecks.invokeMerge('@flecks/socket.intercom'); debug('intercom hooks(%O)', hooks); this.localIntercom = async ({payload, type}, fn) => { debug('customHook: %s(%o)', type, payload); @@ -31,13 +31,13 @@ export default class SocketServer { async connect() { this.io = SocketIoServer(this.httpServer, { - ...await this.flecks.invokeMergeAsync('@flecks/socket/server'), + ...await this.flecks.invokeMergeAsync('@flecks/socket.server'), serveClient: false, }); this.flecks.set('$flecks/socket.io', this.io); this.io.use(this.makeSocketMiddleware()); - this.io.on('@flecks/socket/intercom', this.localIntercom); - this.flecks.invoke('@flecks/socket/server.io', this); + this.io.on('@flecks/socket.intercom', this.localIntercom); + this.flecks.invoke('@flecks/socket.server.io', this); this.io.on('connect', this.onConnect); } @@ -47,7 +47,7 @@ export default class SocketServer { makeSocketMiddleware() { const {app} = this.httpServer; - const middleware = this.flecks.makeMiddleware('@flecks/socket/server/request.socket'); + const middleware = this.flecks.makeMiddleware('@flecks/socket/server.request.socket'); return async (socket, next) => { Object.defineProperty(socket.handshake, 'ip', { configurable: true, @@ -72,7 +72,7 @@ export default class SocketServer { req.flecks = this.flecks; req.intercom = createIntercom(this, 'socket'); req.sockets = this; - this.flecks.invokeSequentialAsync('@flecks/socket/server/connect', serverSocket); + this.flecks.invokeSequentialAsync('@flecks/socket/server.connect', serverSocket); } static send(flecks, nsp, packetOrDehydrated) { diff --git a/packages/user/build/dox/hooks.js b/packages/user/build/dox/hooks.js index cd7c19c..6ccbe07 100644 --- a/packages/user/build/dox/hooks.js +++ b/packages/user/build/dox/hooks.js @@ -7,7 +7,7 @@ export default { * * See: https://www.npmjs.com/package/express-session */ - '@flecks/user/session': () => ({ + '@flecks/user.session': () => ({ saveUninitialized: true, }), }, diff --git a/packages/user/src/index.js b/packages/user/src/index.js index a1478e6..5365af5 100644 --- a/packages/user/src/index.js +++ b/packages/user/src/index.js @@ -10,11 +10,11 @@ export * from './state/users'; export default { [Hooks]: { - '@flecks/redux/slices': () => ({ + '@flecks/redux.slices': () => ({ user, users, }), - '@flecks/socket/packets': (flecks) => ({ + '@flecks/socket.packets': (flecks) => ({ Logout: Logout(flecks), }), }, diff --git a/packages/user/src/local/server/index.js b/packages/user/src/local/server/index.js index 69e2234..5d8ab9c 100644 --- a/packages/user/src/local/server/index.js +++ b/packages/user/src/local/server/index.js @@ -6,14 +6,14 @@ import LocalStrategy from 'passport-local'; export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ failureRedirect: '/', successRedirect: '/', }), - '@flecks/db/server/models.decorate': ( + '@flecks/db/server.models.decorate': ( Flecks.decorate(require.context('./models/decorators', false, /\.js$/)) ), - '@flecks/http/routes': (flecks) => { + '@flecks/http.routes': (flecks) => { const {failureRedirect, successRedirect} = flecks.get('@flecks/user/local/server'); return [ { @@ -23,7 +23,7 @@ export default { }, ]; }, - '@flecks/repl/commands': (flecks) => { + '@flecks/repl.commands': (flecks) => { const {User} = flecks.get('$flecks/db.models'); return { createUser: async (spec) => { @@ -45,7 +45,7 @@ export default { }, }; }, - '@flecks/server/up': (flecks) => { + '@flecks/server.up': (flecks) => { passport.use(new LocalStrategy( {usernameField: 'email'}, async (email, password, fn) => { diff --git a/packages/user/src/server/index.js b/packages/user/src/server/index.js index 57e3c11..8ce06c8 100644 --- a/packages/user/src/server/index.js +++ b/packages/user/src/server/index.js @@ -6,11 +6,11 @@ const debug = D('@flecks/user/passport'); export default { [Hooks]: { - '@flecks/db/server/models': Flecks.provide(require.context('./models', false, /\.js$/)), - '@flecks/http/server/request.route': (flecks) => (req, res, next) => { - debug('@flecks/http/server/request.route: passport.initialize()'); + '@flecks/db/server.models': Flecks.provide(require.context('./models', false, /\.js$/)), + '@flecks/http/server.request.route': (flecks) => (req, res, next) => { + debug('@flecks/http/server.request.route: passport.initialize()'); passport.initialize()(req, res, () => { - debug('@flecks/http/server/request.route: passport.session()'); + debug('@flecks/http/server.request.route: passport.session()'); passport.session()(req, res, () => { if (!req.user) { const {User} = flecks.get('$flecks/db.models'); @@ -21,7 +21,7 @@ export default { }); }); }, - '@flecks/http/routes': () => [ + '@flecks/http.routes': () => [ { method: 'get', path: '/auth/logout', @@ -31,7 +31,7 @@ export default { }, }, ], - '@flecks/server/up': (flecks) => { + '@flecks/server.up': (flecks) => { passport.serializeUser((user, fn) => fn(null, user.id)); passport.deserializeUser(async (id, fn) => { const {User} = flecks.get('$flecks/db.models'); @@ -43,7 +43,7 @@ export default { } }); }, - '@flecks/socket/intercom': () => ({ + '@flecks/socket.intercom': () => ({ '@flecks/user/users': async (sids, server) => { const sockets = await server.sockets(); return sids @@ -57,10 +57,10 @@ export default { ); }, }), - '@flecks/socket/server/request.socket': (flecks) => (socket, next) => { - debug('@flecks/socket/server/request.socket: passport.initialize()'); + '@flecks/socket/server.request.socket': (flecks) => (socket, next) => { + debug('@flecks/socket/server.request.socket: passport.initialize()'); passport.initialize()(socket.handshake, undefined, () => { - debug('@flecks/socket/server/request.socket: passport.session()'); + debug('@flecks/socket/server.request.socket: passport.session()'); passport.session()(socket.handshake, undefined, async () => { /* eslint-disable no-param-reassign */ if (!socket.handshake.user) { diff --git a/packages/user/src/session/server.js b/packages/user/src/session/server.js index 7678a99..6cd8597 100644 --- a/packages/user/src/session/server.js +++ b/packages/user/src/session/server.js @@ -6,21 +6,21 @@ const debug = D('@flecks/user/session'); export default { [Hooks]: { - '@flecks/core/config': () => ({ + '@flecks/core.config': () => ({ cookieSecret: ( 'Set the FLECKS_ENV_FLECKS_USER_SESSION_SERVER_cookieSecret environment variable!' ), }), - '@flecks/http/server/request.route': (flecks) => { + '@flecks/http/server.request.route': (flecks) => { const urle = express.urlencoded({extended: true}); return (req, res, next) => { - debug('@flecks/http/server/request.route: express.urlencoded()'); + debug('@flecks/http/server.request.route: express.urlencoded()'); urle(req, res, (error) => { if (error) { next(error); return; } - debug('@flecks/http/server/request.route: session()'); + debug('@flecks/http/server.request.route: session()'); flecks.get('$flecks/user.session')(req, res, (error) => { if (error) { next(error); @@ -32,17 +32,17 @@ export default { }); }; }, - '@flecks/server/up': async (flecks) => { + '@flecks/server.up': async (flecks) => { flecks.set('$flecks/user.session', expressSession({ resave: false, sameSite: true, saveUninitialized: false, secret: flecks.get('@flecks/user/session/server.cookieSecret'), - ...await flecks.invokeMergeAsync('@flecks/user/session'), + ...await flecks.invokeMergeAsync('@flecks/user.session'), })); }, - '@flecks/socket/server/request.socket': (flecks) => (socket, next) => { - debug('@flecks/socket/server/request.socket: session()'); + '@flecks/socket/server.request.socket': (flecks) => (socket, next) => { + debug('@flecks/socket/server.request.socket: session()'); flecks.get('$flecks/user.session')(socket.handshake, {}, () => { const id = socket.handshake.session?.id; socket.join(id);