Skip to content

Commit

Permalink
feat: added json parser options to startFlowsServer (#570)
Browse files Browse the repository at this point in the history
this just a cleanup of #193

Co-authored-by: tzahush
  • Loading branch information
pavelgj authored Jul 10, 2024
1 parent 8c1767d commit 4aa1db3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion js/flow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"npm-run-all": "^4.1.5",
"tsup": "^8.0.2",
"typescript": "^4.9.0",
"tsx": "^4.7.1"
"tsx": "^4.7.1",
"@types/body-parser": "^1.19.5"
},
"files": [
"genkit-ui",
Expand Down
15 changes: 8 additions & 7 deletions js/flow/src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,38 @@

import {
Action,
defineAction,
FlowError,
FlowState,
FlowStateSchema,
FlowStateStore,
Operation,
StreamingCallback,
defineAction,
getStreamingCallback,
config as globalConfig,
isDevEnv,
Operation,
StreamingCallback,
} from '@genkit-ai/core';
import { logger } from '@genkit-ai/core/logging';
import { toJsonSchema } from '@genkit-ai/core/schema';
import {
SPAN_TYPE_ATTR,
newTrace,
setCustomMetadataAttribute,
setCustomMetadataAttributes,
SPAN_TYPE_ATTR,
} from '@genkit-ai/core/tracing';
import { SpanStatusCode } from '@opentelemetry/api';
import * as bodyParser from 'body-parser';
import { CorsOptions, default as cors } from 'cors';
import { default as cors, CorsOptions } from 'cors';
import express from 'express';
import { performance } from 'node:perf_hooks';
import * as z from 'zod';
import { Context } from './context.js';
import {
FlowExecutionError,
FlowStillRunningError,
InterruptError,
getErrorMessage,
getErrorStack,
InterruptError,
} from './errors.js';
import * as telemetry from './telemetry.js';
import {
Expand Down Expand Up @@ -844,12 +844,13 @@ export function startFlowsServer(params?: {
port?: number;
cors?: CorsOptions;
pathPrefix?: string;
jsonParserOptions?: bodyParser.OptionsJson;
}) {
const port =
params?.port || (process.env.PORT ? parseInt(process.env.PORT) : 0) || 3400;
const pathPrefix = params?.pathPrefix ?? '';
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.json(params?.jsonParserOptions));
app.use(cors(params?.cors));

const flows = params?.flows || createdFlows();
Expand Down
3 changes: 3 additions & 0 deletions js/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4aa1db3

Please sign in to comment.