UNPKG

@trifrost/core

Version:

Blazingly fast, runtime-agnostic server framework for modern edge and node environments

19 lines (18 loc) 827 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mount = mount; const constants_1 = require("../../../types/constants"); const Generic_1 = require("../../../utils/Generic"); const atomic_1 = require("./atomic"); function mount(router, path, module) { /* Set mount path on module */ module.setMountPath(path); router.get(path, ctx => { /* Set js mime */ ctx.setType(constants_1.MimeTypes.JS); const debug = (0, Generic_1.isDevMode)(ctx.env); return ctx.text((0, atomic_1.ARC_GLOBAL)(debug) + (module.isAtomic ? atomic_1.ATOMIC_GLOBAL : atomic_1.ARC_GLOBAL_OBSERVER), /* If not in dev mode add cache control */ !debug ? { status: 200, cacheControl: { type: 'public', maxage: 86400, immutable: true } } : { status: 200 }); }); }