zingzong1073
zingzong1073
CDCloudflare Developers
Created by zingzong1073 on 12/11/2023 in #pages-help
Exporting multiple functions in middleware plugins
I would also like to double check some details: - I believe we can chain mutliple plugins like so:
// functions/myPlugin.ts

export const onRequestFunction1 = (context) => {
// Your implementation for the first onRequest function
};

export const onRequestFunction2 = (context) => {
// Your implementation for the second onRequest function
};

export const onRequestFunction3 = (context) => {
// Your implementation for the third onRequest function
};
// functions/myPlugin.ts

export const onRequestFunction1 = (context) => {
// Your implementation for the first onRequest function
};

export const onRequestFunction2 = (context) => {
// Your implementation for the second onRequest function
};

export const onRequestFunction3 = (context) => {
// Your implementation for the third onRequest function
};
and import them like so:
// functions/someRoute.ts

import { onRequestFunction1, onRequestFunction2, onRequestFunction3 } from '@your/cloudflare-plugin';

export const onRequestChain = [
onRequestFunction1,
onRequestFunction2,
onRequestFunction3,
];
// functions/someRoute.ts

import { onRequestFunction1, onRequestFunction2, onRequestFunction3 } from '@your/cloudflare-plugin';

export const onRequestChain = [
onRequestFunction1,
onRequestFunction2,
onRequestFunction3,
];
Can anybody confirm this?
3 replies