refactor: http -> web
This commit is contained in:
parent
c58bf65830
commit
622afb628a
|
@ -75,11 +75,11 @@ At its core, flecks is a collection of modules that use [hooks](packages/core/bu
|
|||
|
||||
Just to give you an idea of the power of hooks, some will be listed here:
|
||||
|
||||
- [`@flecks/http/server.stream.html`](https://github.com/cha0s/flecks/blob/gh-pages/hooks.md#fleckshttpserverstreamhtml)
|
||||
- [`@flecks/web/server.stream.html`](https://github.com/cha0s/flecks/blob/gh-pages/hooks.md#fleckshttpserverstreamhtml)
|
||||
> Compose the server-side HTML stream. This is how SSR slides in.
|
||||
- [`@flecks/docker.containers`](https://github.com/cha0s/flecks/blob/gh-pages/hooks.md#flecksdockercontainers)
|
||||
> Define [Docker](https://www.docker.com/) containers to automatically come up next to your app. See [`@flecks/redis`'s implementation](packages/redis/src/containers.js). `@flecks/docker` also generates `Dockerfile` and `docker-compose.yml` and provides the [CLI command](https://github.com/cha0s/flecks/blob/gh-pages/hooks.md#fleckscorecommands) `flecks docker` for even more.
|
||||
- [`@flecks/http/server.request.route`](https://github.com/cha0s/flecks/blob/gh-pages/hooks.md#fleckshttpserverrequestroute)
|
||||
- [`@flecks/web/server.request.route`](https://github.com/cha0s/flecks/blob/gh-pages/hooks.md#fleckshttpserverrequestroute)
|
||||
> Define [Express](http://expressjs.com/) middleware that runs when an HTTP route is hit.
|
||||
- [... and many more on the hook reference page](https://github.com/cha0s/flecks/blob/gh-pages/hooks.md)
|
||||
|
||||
|
|
2
TODO.md
2
TODO.md
|
@ -28,5 +28,5 @@
|
|||
- [ ] governor fails if not in server up
|
||||
- [ ] redux store provider fails if not in request
|
||||
- [ ] client hooks will run on server if they're explicit in `flecks.yml`. Should there be an implicit `!client` when bootstrapping the server?
|
||||
- [ ] rename `@flecks/http` to `@flecks/web`
|
||||
- [ ] rename `@flecks/web` to `@flecks/web`
|
||||
- [ ] simultaneous babel compilation across all compiled flecks
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"@flecks/dox": "^1.2.0",
|
||||
"@flecks/fleck": "^1.2.0",
|
||||
"@flecks/governor": "^1.2.0",
|
||||
"@flecks/http": "^1.2.0",
|
||||
"@flecks/react": "^1.2.0",
|
||||
"@flecks/redis": "^1.2.0",
|
||||
"@flecks/redux": "^1.2.0",
|
||||
|
@ -29,6 +28,7 @@
|
|||
"@flecks/server": "^1.2.0",
|
||||
"@flecks/socket": "^1.2.0",
|
||||
"@flecks/user": "^1.2.0",
|
||||
"@flecks/web": "^1.2.0",
|
||||
"lerna": "^3.22.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ export default {
|
|||
},
|
||||
}),
|
||||
'@flecks/db/server.models': Flecks.provide(require.context('./models', false, /\.js$/)),
|
||||
'@flecks/http/server.request.route': (flecks) => {
|
||||
'@flecks/web/server.request.route': (flecks) => {
|
||||
const {http} = flecks.get('@flecks/governor/server');
|
||||
const limiter = flecks.get('$flecks/governor.http.limiter');
|
||||
return async (req, res, next) => {
|
||||
|
@ -56,7 +56,7 @@ export default {
|
|||
};
|
||||
},
|
||||
'@flecks/server.up': async (flecks) => {
|
||||
if (flecks.fleck('@flecks/http/server')) {
|
||||
if (flecks.fleck('@flecks/web/server')) {
|
||||
const {http} = flecks.get('@flecks/governor/server');
|
||||
const limiter = await createLimiter(
|
||||
flecks,
|
||||
|
|
|
@ -12,7 +12,7 @@ export {FlecksContext};
|
|||
|
||||
export default {
|
||||
[Hooks]: {
|
||||
'@flecks/http/client.up': async (flecks) => {
|
||||
'@flecks/web/client.up': async (flecks) => {
|
||||
const {ssr} = flecks.get('@flecks/react');
|
||||
debug('%sing...', ssr ? 'hydrat' : 'render');
|
||||
(ssr ? hydrate : render)(
|
||||
|
|
|
@ -14,7 +14,7 @@ export default {
|
|||
.prepend('.web.jsx');
|
||||
});
|
||||
},
|
||||
'@flecks/http/server.stream.html': (stream, req, flecks) => (
|
||||
'@flecks/web/server.stream.html': (stream, req, flecks) => (
|
||||
flecks.get('@flecks/react.ssr') ? ssr(stream, req, flecks) : stream
|
||||
),
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@ const debug = D('@flecks/redux/server');
|
|||
|
||||
export default {
|
||||
[Hooks]: {
|
||||
'@flecks/http/server.request.route': (flecks) => async (req, res, next) => {
|
||||
'@flecks/web/server.request.route': (flecks) => async (req, res, next) => {
|
||||
const slices = await ensureUniqueReduction(flecks, '@flecks/redux.slices');
|
||||
const reducer = createReducer(flecks, slices);
|
||||
// Let the slices have a(n async) chance to hydrate with server data.
|
||||
|
@ -25,7 +25,7 @@ export default {
|
|||
req.redux = await configureStore(flecks, reducer, {preloadedState});
|
||||
next();
|
||||
},
|
||||
'@flecks/http.config': async (req) => ({
|
||||
'@flecks/web.config': async (req) => ({
|
||||
'@flecks/redux/client': {
|
||||
preloadedState: req.redux.getState(),
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@ import SocketClient from './socket';
|
|||
|
||||
export default {
|
||||
[Hooks]: {
|
||||
'@flecks/http/client.up': (flecks) => {
|
||||
'@flecks/web/client.up': (flecks) => {
|
||||
const socket = new SocketClient(flecks);
|
||||
flecks.set('$flecks/socket.socket', socket);
|
||||
socket.connect();
|
||||
|
|
|
@ -17,7 +17,7 @@ export default {
|
|||
{check: badPacketsCheck},
|
||||
));
|
||||
},
|
||||
'@flecks/http.config': async (
|
||||
'@flecks/web.config': async (
|
||||
req,
|
||||
{config: {'@flecks/socket': {'packets.decorate': decorators = ['...']}}},
|
||||
) => ({
|
||||
|
|
|
@ -5,11 +5,11 @@ import Sockets from './sockets';
|
|||
|
||||
export default {
|
||||
[Hooks]: {
|
||||
'@flecks/http/server.request.socket': ({config: {'$flecks/socket.sockets': sockets}}) => (req, res, next) => {
|
||||
'@flecks/web/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/web/server.up': async (httpServer, flecks) => {
|
||||
const sockets = new Sockets(httpServer, flecks);
|
||||
await sockets.connect();
|
||||
flecks.set('$flecks/socket.sockets', sockets);
|
||||
|
|
|
@ -19,7 +19,7 @@ export default {
|
|||
'@flecks/db/server.models.decorate': (
|
||||
Flecks.decorate(require.context('./models/decorators', false, /\.js$/))
|
||||
),
|
||||
'@flecks/http.routes': (flecks) => {
|
||||
'@flecks/web.routes': (flecks) => {
|
||||
const {failureRedirect, successRedirect} = flecks.get('@flecks/user/local/server');
|
||||
return [
|
||||
{
|
||||
|
|
|
@ -7,10 +7,10 @@ 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/web/server.request.route': (flecks) => (req, res, next) => {
|
||||
debug('@flecks/web/server.request.route: passport.initialize()');
|
||||
passport.initialize()(req, res, () => {
|
||||
debug('@flecks/http/server.request.route: passport.session()');
|
||||
debug('@flecks/web/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/web.routes': () => [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/auth/logout',
|
||||
|
|
|
@ -16,16 +16,16 @@ export default {
|
|||
'Set the FLECKS_ENV_FLECKS_USER_SESSION_SERVER_cookieSecret environment variable!'
|
||||
),
|
||||
}),
|
||||
'@flecks/http/server.request.route': (flecks) => {
|
||||
'@flecks/web/server.request.route': (flecks) => {
|
||||
const urle = express.urlencoded({extended: true});
|
||||
return (req, res, next) => {
|
||||
debug('@flecks/http/server.request.route: express.urlencoded()');
|
||||
debug('@flecks/web/server.request.route: express.urlencoded()');
|
||||
urle(req, res, (error) => {
|
||||
if (error) {
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
debug('@flecks/http/server.request.route: session()');
|
||||
debug('@flecks/web/server.request.route: session()');
|
||||
flecks.get('$flecks/user.session')(req, res, (error) => {
|
||||
if (error) {
|
||||
next(error);
|
||||
|
|
|
@ -21,7 +21,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|||
|
||||
## [1.2.1](https://github.com/cha0s/flecks/compare/v1.2.0...v1.2.1) (2022-03-08)
|
||||
|
||||
**Note:** Version bump only for package @flecks/http
|
||||
**Note:** Version bump only for package @flecks/web
|
||||
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|||
|
||||
## [1.1.1](https://github.com/cha0s/flecks/compare/v1.1.0...v1.1.1) (2022-02-28)
|
||||
|
||||
**Note:** Version bump only for package @flecks/http
|
||||
**Note:** Version bump only for package @flecks/web
|
||||
|
||||
|
||||
|
||||
|
@ -67,4 +67,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|||
|
||||
## [1.0.2](https://github.com/cha0s/flecks/compare/v1.0.1...v1.0.2) (2022-02-28)
|
||||
|
||||
**Note:** Version bump only for package @flecks/http
|
||||
**Note:** Version bump only for package @flecks/web
|
|
@ -5,14 +5,14 @@ export default {
|
|||
/**
|
||||
* Define sequential actions to run when the client comes up.
|
||||
*/
|
||||
'@flecks/http/client.up': async () => {
|
||||
'@flecks/web/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/web.config': (req) => ({
|
||||
someClientFleck: {
|
||||
someConfig: req.someConfig,
|
||||
},
|
||||
|
@ -20,7 +20,7 @@ export default {
|
|||
/**
|
||||
* Define HTTP routes.
|
||||
*/
|
||||
'@flecks/http.routes': () => [
|
||||
'@flecks/web.routes': () => [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/some-path',
|
||||
|
@ -33,14 +33,14 @@ export default {
|
|||
/**
|
||||
* Define middleware to run when a route is matched.
|
||||
*/
|
||||
'@flecks/http/server.request.route': () => (req, res, next) => {
|
||||
'@flecks/web/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/web/server.request.socket': () => (req, res, next) => {
|
||||
// Express-style route middleware...
|
||||
next();
|
||||
},
|
||||
|
@ -49,13 +49,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/web/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/web/server.up': async () => {
|
||||
await youCanDoAsyncThingsHere();
|
||||
},
|
||||
},
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@flecks/http",
|
||||
"name": "@flecks/web",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/cha0s/flecks.git",
|
|
@ -11,12 +11,12 @@ 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/web.config')];
|
||||
const debug = D(config['@flecks/core']?.id || 'flecks');
|
||||
debug('loading runtime...');
|
||||
const {default: loader} = await __non_webpack_import__(
|
||||
/* @preserve webpackChunkName: "flecks-runtime" */
|
||||
'@flecks/http/runtime',
|
||||
'@flecks/web/runtime',
|
||||
);
|
||||
const runtime = await loader(progress.update.bind(progress));
|
||||
progress.finish();
|
||||
|
@ -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/web/client.up');
|
||||
debug('up!');
|
||||
}
|
||||
catch (error) {
|
|
@ -1,6 +1,6 @@
|
|||
import {D} from '@flecks/core';
|
||||
|
||||
const debug = D('@flecks/http/progress');
|
||||
const debug = D('@flecks/web/progress');
|
||||
|
||||
export default class Progress {
|
||||
|
|
@ -7,7 +7,7 @@ module.exports = (flecks) => (neutrino) => {
|
|||
devPublic,
|
||||
devStats,
|
||||
port,
|
||||
} = flecks.get('@flecks/http/server');
|
||||
} = flecks.get('@flecks/web/server');
|
||||
neutrino.use(devServer({
|
||||
historyApiFallback: {
|
||||
disableDotRule: true,
|
|
@ -19,7 +19,7 @@ module.exports = async (flecks) => {
|
|||
},
|
||||
use: [
|
||||
({config, options}) => {
|
||||
const dll = flecks.get('@flecks/http/server.dll');
|
||||
const dll = flecks.get('@flecks/web/server.dll');
|
||||
if (dll.length > 0) {
|
||||
// Build the library and manifest.
|
||||
config.context(options.root);
|
||||
|
@ -65,7 +65,7 @@ module.exports = async (flecks) => {
|
|||
config.resolve.modules
|
||||
.merge([join(FLECKS_CORE_ROOT, 'node_modules')]);
|
||||
// Reporting.
|
||||
config.stats(flecks.get('@flecks/http/server.stats'));
|
||||
config.stats(flecks.get('@flecks/web/server.stats'));
|
||||
}
|
||||
},
|
||||
],
|
|
@ -20,7 +20,7 @@ module.exports = async (flecks) => {
|
|||
// Build configuration.
|
||||
const build = async () => {
|
||||
const root = await realpath(
|
||||
dirname(R.resolve(join(flecks.resolve('@flecks/http'), 'entry.js'))),
|
||||
dirname(R.resolve(join(flecks.resolve('@flecks/web'), 'entry.js'))),
|
||||
);
|
||||
return (neutrino) => {
|
||||
const {config, options} = neutrino;
|
||||
|
@ -38,7 +38,7 @@ module.exports = async (flecks) => {
|
|||
entry: join(root, 'server', 'build', 'tests'),
|
||||
title: 'Testbed',
|
||||
};
|
||||
options.output = join(originalOutput, flecks.get('@flecks/http/server.output'));
|
||||
options.output = join(originalOutput, flecks.get('@flecks/web/server.output'));
|
||||
// Load HTML.
|
||||
neutrino.use(htmlLoader());
|
||||
Object.entries(options.mains).forEach(([name, mainsConfig]) => {
|
||||
|
@ -137,12 +137,12 @@ module.exports = async (flecks) => {
|
|||
config.resolve.modules
|
||||
.merge([join(FLECKS_CORE_ROOT, 'node_modules')]);
|
||||
// Reporting.
|
||||
config.stats(flecks.get('@flecks/http/server.stats'));
|
||||
config.stats(flecks.get('@flecks/web/server.stats'));
|
||||
// Inline the main entrypoint (nice for FCP).
|
||||
config
|
||||
.plugin('inline-chunks')
|
||||
.use(InlineChunkHtmlPlugin, [HtmlWebpackPlugin, [/^assets\/index(\.[^.]*)?\.js$/]]);
|
||||
const dll = flecks.get('@flecks/http/server.dll');
|
||||
const dll = flecks.get('@flecks/web/server.dll');
|
||||
if (!isProduction && dll.length > 0) {
|
||||
const manifest = join(
|
||||
FLECKS_CORE_ROOT,
|
|
@ -8,7 +8,7 @@ const {D} = require('@flecks/core');
|
|||
const {Flecks, require: R} = require('@flecks/core/server');
|
||||
const glob = require('glob');
|
||||
|
||||
const debug = D('@flecks/http/runtime');
|
||||
const debug = D('@flecks/web/runtime');
|
||||
|
||||
module.exports = async (flecks) => {
|
||||
debug('bootstrapping flecks...');
|
||||
|
@ -41,12 +41,12 @@ module.exports = async (flecks) => {
|
|||
)
|
||||
)
|
||||
.filter((filename) => !!filename);
|
||||
const runtime = await realpath(R.resolve(join(httpFlecks.resolve('@flecks/http'), 'runtime')));
|
||||
const runtime = await realpath(R.resolve(join(httpFlecks.resolve('@flecks/web'), 'runtime')));
|
||||
const fullresolve = (fleck, path) => realpath(R.resolve(join(httpFlecks.resolve(fleck), path)));
|
||||
const entry = await fullresolve('@flecks/http', 'entry');
|
||||
const importLoader = await fullresolve('@flecks/http', 'import-loader');
|
||||
const entry = await fullresolve('@flecks/web', 'entry');
|
||||
const importLoader = await fullresolve('@flecks/web', 'import-loader');
|
||||
const tests = await realpath(R.resolve(
|
||||
join(httpFlecks.resolve('@flecks/http'), 'server', 'build', 'tests'),
|
||||
join(httpFlecks.resolve('@flecks/web'), 'server', 'build', 'tests'),
|
||||
));
|
||||
const testsSource = (await readFile(tests)).toString();
|
||||
return (neutrino) => {
|
||||
|
@ -56,7 +56,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/web.config')],",
|
||||
' flecks: Object.fromEntries(await Promise.all([',
|
||||
paths
|
||||
.map(([path]) => [
|
||||
|
@ -92,7 +92,7 @@ module.exports = async (flecks) => {
|
|||
source: source.join('\n'),
|
||||
});
|
||||
config.resolve.alias
|
||||
.set('@flecks/http/runtime$', runtime);
|
||||
.set('@flecks/web/runtime$', runtime);
|
||||
flecks.runtimeCompiler(httpFlecks.resolver, 'http', neutrino);
|
||||
// Handle runtime import.
|
||||
config.module
|
||||
|
@ -138,7 +138,7 @@ module.exports = async (flecks) => {
|
|||
.loader(runtime)
|
||||
.options({
|
||||
source: testsSource.replace(
|
||||
"await import('@flecks/http/tests');",
|
||||
"await import('@flecks/web/tests');",
|
||||
[
|
||||
'const tests = {};',
|
||||
Object.entries(
|
|
@ -9,7 +9,7 @@ window.document.body.appendChild(mochaDiv);
|
|||
mocha.setup('bdd');
|
||||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved
|
||||
await import('@flecks/http/tests');
|
||||
await import('@flecks/web/tests');
|
||||
|
||||
mocha.run();
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import {Transform} from 'stream';
|
||||
|
||||
const config = async (flecks, req) => {
|
||||
const httpConfig = await flecks.invokeMergeAsync('@flecks/http.config', req);
|
||||
const {config} = flecks.get('$flecks/http.flecks');
|
||||
const httpConfig = await flecks.invokeMergeAsync('@flecks/web.config', req);
|
||||
const {config} = flecks.get('$flecks/web.flecks');
|
||||
return Object.keys(config)
|
||||
.filter((path) => !path.startsWith('$'))
|
||||
.filter((path) => !path.endsWith('/server'))
|
||||
|
@ -20,7 +20,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/web.config')] = JSON.parse(decodeURIComponent("${
|
||||
codedConfig
|
||||
}"));`;
|
||||
};
|
|
@ -13,33 +13,33 @@ const {
|
|||
NODE_ENV,
|
||||
} = process.env;
|
||||
|
||||
const debug = D('@flecks/http/server/http');
|
||||
const debug = D('@flecks/web/server/http');
|
||||
|
||||
const deliverHtmlStream = (stream, flecks, req, res) => {
|
||||
flecks.invokeComposed('@flecks/http/server.stream.html', stream, req).pipe(res);
|
||||
flecks.invokeComposed('@flecks/web/server.stream.html', stream, req).pipe(res);
|
||||
};
|
||||
|
||||
export const createHttpServer = async (flecks) => {
|
||||
const {trust} = flecks.get('@flecks/http/server');
|
||||
const {trust} = flecks.get('@flecks/web/server');
|
||||
const {
|
||||
devHost,
|
||||
devPort,
|
||||
host,
|
||||
output,
|
||||
port,
|
||||
} = flecks.get('@flecks/http/server');
|
||||
} = flecks.get('@flecks/web/server');
|
||||
const app = express();
|
||||
app.set('trust proxy', trust);
|
||||
const httpServer = createServer(app);
|
||||
httpServer.app = app;
|
||||
flecks.set('$flecks/http/server.instance', httpServer);
|
||||
flecks.set('$flecks/web/server.instance', httpServer);
|
||||
// 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/web/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/web/server.request.route');
|
||||
const routes = flatten(flecks.invokeFlat('@flecks/web.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/web/server.up', httpServer));
|
||||
debug('HTTP server up @ %s!', [host, port].filter((e) => !!e).join(':'));
|
||||
resolve();
|
||||
});
|
|
@ -14,7 +14,7 @@ const {
|
|||
FLECKS_CORE_ROOT = process.cwd(),
|
||||
} = process.env;
|
||||
|
||||
const debug = D('@flecks/http/server');
|
||||
const debug = D('@flecks/web/server');
|
||||
|
||||
export default {
|
||||
[Hooks]: {
|
||||
|
@ -69,7 +69,7 @@ export default {
|
|||
},
|
||||
'@flecks/core.build.alter': async (neutrinoConfigs, flecks) => {
|
||||
// Don't build if there's a fleck target.
|
||||
if (neutrinoConfigs.fleck && !flecks.get('@flecks/http/server.forceBuildWithFleck')) {
|
||||
if (neutrinoConfigs.fleck && !flecks.get('@flecks/web/server.forceBuildWithFleck')) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
delete neutrinoConfigs.http;
|
||||
return;
|
||||
|
@ -81,7 +81,7 @@ export default {
|
|||
delete neutrinoConfigs['http-vendor'];
|
||||
}
|
||||
// Only build if something actually changed.
|
||||
const dll = flecks.get('@flecks/http/server.dll');
|
||||
const dll = flecks.get('@flecks/web/server.dll');
|
||||
if (dll.length > 0) {
|
||||
const manifest = join(
|
||||
FLECKS_CORE_ROOT,
|
||||
|
@ -224,13 +224,13 @@ export default {
|
|||
platforms: ['client', '!server'],
|
||||
});
|
||||
debug('bootstrapped');
|
||||
flecks.set('$flecks/http.flecks', httpFlecks);
|
||||
flecks.set('$flecks/web.flecks', httpFlecks);
|
||||
},
|
||||
'@flecks/core.targets': (flecks) => [
|
||||
'http',
|
||||
...(flecks.get('@flecks/http/server.dll').length > 0 ? ['http-vendor'] : []),
|
||||
...(flecks.get('@flecks/web/server.dll').length > 0 ? ['http-vendor'] : []),
|
||||
],
|
||||
'@flecks/http.routes': (flecks) => [
|
||||
'@flecks/web.routes': (flecks) => [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/flecks.config.js',
|
||||
|
@ -240,10 +240,10 @@ export default {
|
|||
},
|
||||
},
|
||||
],
|
||||
'@flecks/http/server.stream.html': inlineConfig,
|
||||
'@flecks/web/server.stream.html': inlineConfig,
|
||||
'@flecks/server.up': (flecks) => createHttpServer(flecks),
|
||||
'@flecks/repl.context': (flecks) => ({
|
||||
httpServer: flecks.get('$flecks/http/server.instance'),
|
||||
httpServer: flecks.get('$flecks/web/server.instance'),
|
||||
}),
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user