Split services into core and request

This commit is contained in:
2026-01-17 16:19:32 -06:00
parent e59bb35ac9
commit 894c841bb7
11 changed files with 76 additions and 71 deletions

View File

@@ -1,24 +1,23 @@
import { contentTypes } from "../content-types";
import { core } from "../core";
import { executionContext } from "../execution-context";
import { httpCodes } from "../http-codes";
import type { RedirectResult, Result } from "../types";
import {services} from '../services'
import { loadFile } from "../util";
import { request } from "./index";
import{loadFile}from'../util'
type NoUser={
type NoUser = {
[key: string]: unknown;
} & {
user?: never;
}
};
const render = async (path: string, ctx?: NoUser): Promise<string> => {
const fullPath = `${executionContext.diachron_root}/templates/${path}.html.njk`;
const template = await loadFile(fullPath);
const user = services.session.getUser();
const context = {user, ...ctx}
const engine = services.conf.templateEngine()
const user = request.session.getUser();
const context = { user, ...ctx };
const engine = core.conf.templateEngine();
const retval = engine.renderTemplate(template, context);
return retval;
@@ -43,4 +42,4 @@ const redirect = (location: string): RedirectResult => {
};
};
export { render, html, redirect };
export { html, redirect, render };