flecks/packages/socket/src/index.js

36 lines
969 B
JavaScript
Raw Normal View History

2022-02-25 04:58:08 -06:00
import {Hooks} from '@flecks/core';
import badPacketsCheck from './packet/bad-packets-check';
import Bundle from './packet/bundle';
import Redirect from './packet/redirect';
import Refresh from './packet/refresh';
export {default as normalize} from './normalize';
export {default as Packet, Packer, ValidationError} from './packet';
export default {
[Hooks]: {
2022-03-08 16:03:06 -06:00
'@flecks/core.starting': (flecks) => {
2022-02-25 04:58:08 -06:00
flecks.set('$flecks/socket.packets', flecks.gather(
2022-03-08 16:03:06 -06:00
'@flecks/socket.packets',
2022-02-25 04:58:08 -06:00
{check: badPacketsCheck},
));
},
2022-03-08 16:03:06 -06:00
'@flecks/http.config': async (
2022-02-25 04:58:08 -06:00
req,
{config: {'@flecks/socket': {'packets.decorate': decorators}}},
) => ({
'@flecks/socket': {
'packets.decorate': decorators.filter(
(decorator) => 'server' !== decorator.split('/').pop(),
),
},
}),
2022-03-08 16:03:06 -06:00
'@flecks/socket.packets': (flecks) => ({
2022-02-25 04:58:08 -06:00
Bundle: Bundle(flecks),
Redirect,
Refresh,
}),
},
};