API reference > @kontsedal/olas-core > definePlugin
definePlugin() function
Identity helper that types an object literal as an OlasPlugin.
Signature:
typescript
export declare function definePlugin(plugin: OlasPlugin): OlasPlugin;Parameters
Parameter | Type | Description |
|---|---|---|
plugin |
Returns:
Example
ts
export const fetchTimer = definePlugin({
name: 'fetch-timer',
setup: () => ({
wrapFetch: async (context, next) => {
const start = performance.now()
try {
return await next()
} finally {
console.log(context.query.id, performance.now() - start)
}
},
}),
})