gateway
gateway copied to clipboard
[Feature] Enable importing this package's contents
What Would You Like to See with the Gateway?
I'd like to import contents like app, HooksManager from this package (currently not possible), and integrate it with my sveltekit app backend, instead of hosting this gateway as another backend server. Example:
// hooks.server.ts
import { app, HooksManager } from '@portkey-ai/gateway'
import { myPlugins } from './myPlugins'
const hooks = (c: Context, next: any) => {
const hooksManager = new HooksManager(myPlugins);
c.set('hooksManager', hooksManager);
c.set('executeHooks', hooksManager.executeHooks.bind(hooksManager));
return next();
};
app.use('*', hooks); // this middleware comes last... I don't think it's gonna work
export async function handle(input) {
// ...
if (url.startsWith('/v1'))
return app.fetch(event.request, undefined, platform?.context)
// ...
}
Currently, I need to put this package into my project repo as git submodule to import app, .etc. I'd be happy if there's no need to use git submodule.
Hint
- need to tweak
rollup.config.js? - package.json will need this kind of stuff?
{
"main": "build/index.js",
"module": "build/index.js",
"types": "build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"import": "./build/index.js",
"require": "./build/index.js"
}
}
}
Context for your Request
No response
Your Twitter/LinkedIn
No response
@noy4 We are not so sure that we want to publish an officially maintained package though, because it would mean maintenance with regards to compatibility in different environments, we've found it best to use the gateway as a standalone application