siliconflow-serverless-client
Version:

28 lines (25 loc) • 914 B
text/typescript
import type { RequestHandler } from 'express';
import { DEFAULT_PROXY_ROUTE, handleRequest } from './index';
/**
* The default Express route for the siliconflow.com client proxy.
*/
export const route = DEFAULT_PROXY_ROUTE;
/**
* The Express route handler for the siliconflow.com client proxy.
*
* @param request The Express request object.
* @param response The Express response object.
* @param next The Express next function.
*/
export const handler: RequestHandler = async (request, response, next) => {
await handleRequest({
id: 'express',
method: request.method,
respondWith: (status, data) => response.status(status).json(data),
getHeaders: () => request.headers,
getHeader: (name) => request.headers[name],
sendHeader: (name, value) => response.setHeader(name, value),
getBody: async () => JSON.stringify(request.body),
});
next();
};