@appsemble/node-utils
Version:
NodeJS utilities used by Appsemble internally.
14 lines • 625 B
JavaScript
import { assertKoaCondition } from '@appsemble/node-utils';
export function createBlockAssetHandler({ getBlockAsset }) {
return async (ctx) => {
const {
// @ts-expect-error Messed up
params: { filename, name, version }, } = ctx;
const blockAsset = await getBlockAsset({ filename, name, version, context: ctx });
assertKoaCondition(blockAsset != null, ctx, 404, 'Block asset not found');
ctx.set('Cache-Control', 'max-age=31536000,immutable');
ctx.body = blockAsset.content;
ctx.type = blockAsset.mime;
};
}
//# sourceMappingURL=blockAssetHandler.js.map