Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Enable importing this package's contents #738

Open
noy4 opened this issue Nov 8, 2024 · 1 comment
Open

[Feature] Enable importing this package's contents #738

noy4 opened this issue Nov 8, 2024 · 1 comment
Labels
enhancement New feature or request triage

Comments

@noy4
Copy link
Contributor

noy4 commented Nov 8, 2024

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

  1. need to tweak rollup.config.js?
  2. 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 noy4 added the enhancement New feature or request label Nov 8, 2024
@github-actions github-actions bot added the triage label Nov 8, 2024
@narengogi
Copy link
Collaborator

narengogi commented Nov 11, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

2 participants