fix: proxy lib exports (#15)
* fix: update proxy package config * fix: proxy lib exports at last
This commit is contained in:
parent
b79e51683b
commit
dcd513c1e7
@ -29,7 +29,7 @@ For Express applications:
|
|||||||
```ts
|
```ts
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
```
|
```
|
||||||
2. Add the proxy route and its handler. Note that if your client lives outside of the express app (i.e. the express app is solely used as an external API for other clients), your will need to allow CORS on the proxy route:
|
2. Add the proxy route and its handler. Note that if your client lives outside of the express app (i.e. the express app is solely used as an external API for other clients), you will need to allow CORS on the proxy route:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import * as falProxy from '@fal-ai/serverless-proxy/express';
|
import * as falProxy from '@fal-ai/serverless-proxy/express';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@fal-ai/serverless-proxy",
|
"name": "@fal-ai/serverless-proxy",
|
||||||
"version": "0.3.0",
|
"version": "0.3.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -21,6 +21,18 @@
|
|||||||
"./express": "./src/express.js",
|
"./express": "./src/express.js",
|
||||||
"./nextjs": "./src/nextjs.js"
|
"./nextjs": "./src/nextjs.js"
|
||||||
},
|
},
|
||||||
|
"typesVersions": {
|
||||||
|
"*": {
|
||||||
|
"express": [
|
||||||
|
"src/express.d.ts"
|
||||||
|
],
|
||||||
|
"nextjs": [
|
||||||
|
"src/nextjs.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"main": "./src/index.js",
|
||||||
|
"types": "./src/index.d.ts",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"express": "^4.0.0",
|
"express": "^4.0.0",
|
||||||
"next": "^13.0.0",
|
"next": "^13.0.0",
|
||||||
|
|||||||
@ -7,6 +7,10 @@ const FAL_KEY_ID = process.env.FAL_KEY_ID || process.env.NEXT_PUBLIC_FAL_KEY_ID;
|
|||||||
const FAL_KEY_SECRET =
|
const FAL_KEY_SECRET =
|
||||||
process.env.FAL_KEY_SECRET || process.env.NEXT_PUBLIC_FAL_KEY_SECRET;
|
process.env.FAL_KEY_SECRET || process.env.NEXT_PUBLIC_FAL_KEY_SECRET;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The proxy behavior that is passed to the proxy handler. This is a subset of
|
||||||
|
* request objects that are used by different frameworks, like Express and NextJS.
|
||||||
|
*/
|
||||||
export interface ProxyBehavior {
|
export interface ProxyBehavior {
|
||||||
id: string;
|
id: string;
|
||||||
method: string;
|
method: string;
|
||||||
@ -59,13 +63,12 @@ function getFalKey(): string | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Next request handler that proxies the request to the fal-serverless
|
* A request handler that proxies the request to the fal-serverless
|
||||||
* endpoint. This is useful so client-side calls to the fal-serverless endpoint
|
* endpoint. This is useful so client-side calls to the fal-serverless endpoint
|
||||||
* can be made without CORS issues and the correct credentials can be added
|
* can be made without CORS issues and the correct credentials can be added
|
||||||
* effortlessly.
|
* effortlessly.
|
||||||
*
|
*
|
||||||
* @param request the Next request object.
|
* @param behavior the request proxy behavior.
|
||||||
* @param response the Next response object.
|
|
||||||
* @returns Promise<any> the promise that will be resolved once the request is done.
|
* @returns Promise<any> the promise that will be resolved once the request is done.
|
||||||
*/
|
*/
|
||||||
export const handleRequest = async (behavior: ProxyBehavior) => {
|
export const handleRequest = async (behavior: ProxyBehavior) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user