UNPKG

@trifrost/core

Version:

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

16 lines (15 loc) 708 B
import { MimeTypes } from '../../../types/constants'; import { isDevMode } from '../../../utils/Generic'; import { ARC_GLOBAL, ARC_GLOBAL_OBSERVER, ATOMIC_GLOBAL } from './atomic'; export function mount(router, path, module) { /* Set mount path on module */ module.setMountPath(path); router.get(path, ctx => { /* Set js mime */ ctx.setType(MimeTypes.JS); const debug = isDevMode(ctx.env); return ctx.text(ARC_GLOBAL(debug) + (module.isAtomic ? ATOMIC_GLOBAL : ARC_GLOBAL_OBSERVER), /* If not in dev mode add cache control */ !debug ? { status: 200, cacheControl: { type: 'public', maxage: 86400, immutable: true } } : { status: 200 }); }); }