oak-cli/templateFiles/initialize.server.ts

43 lines
1.8 KiB
TypeScript

import { mergeConcatMany } from 'oak-domain/lib/utils/lodash';
import BackendRuntimeContext from '@project/context/BackendRuntimeContext';
import FrontendRuntimeContext from '@project/context/FrontendRuntimeContext';
import connector from '@project/config/connector';
import { EntityDict, storageSchema } from '@project/oak-app-domain';
import checkers from '@project/checkers';
import { create as createFeatures, FeatureDict } from '@project/features';
import common from '@project/configuration';
import render from '@project/configuration/render';
// import ogbCheckers from 'oak-general-business/es/checkers';
// import { create as createOgbFeatures, FeatureDict as OgbFeatureDict } from 'oak-general-business/es/features';
// import ogbCommon from 'oak-general-business/es/configuration';
// import ogbRender from 'oak-general-business/es/configuration/render';
import { initialize as initFrontend } from 'oak-frontend-base/es/initialize';
import { BasicFeatures } from 'oak-frontend-base/es/features';
export default function initialize() {
const totalCheckers = mergeConcatMany([checkers] as Array<typeof checkers>)!,
totalCommon = mergeConcatMany([common] as Array<typeof common>)!,
totalRender = mergeConcatMany([render] as Array<typeof render>)!;
const totalFeatures = {} as FeatureDict & BasicFeatures<EntityDict>;
const { features } = initFrontend<EntityDict, BackendRuntimeContext, FrontendRuntimeContext>(
storageSchema,
(store) => new FrontendRuntimeContext(store, totalFeatures),
connector,
totalCheckers,
totalCommon,
totalRender
);
Object.assign(totalFeatures, features);
const appFeatures = createFeatures(totalFeatures);
Object.assign(totalFeatures, appFeatures);
return {
features: totalFeatures,
};
}