Skip to content

Commit

Permalink
fix(core): Lazy-load express-openapi-validator to reduce initial memo…
Browse files Browse the repository at this point in the history
…ry spike (no-changelog) (n8n-io#7111)
  • Loading branch information
netroy authored Sep 5, 2023
1 parent 36f2469 commit cc37a50
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/PublicApi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import fs from 'fs/promises';
import path from 'path';

import validator from 'validator';
import { middleware as openapiValidatorMiddleware } from 'express-openapi-validator';
import YAML from 'yamljs';
import type { HttpError } from 'express-openapi-validator/dist/framework/types';
import type { OpenAPIV3 } from 'openapi-types';
Expand Down Expand Up @@ -55,10 +54,11 @@ async function createApiRouter(
res.sendFile(openApiSpecPath);
});

const { middleware: openApiValidatorMiddleware } = await import('express-openapi-validator');
apiController.use(
`/${publicApiEndpoint}/${version}`,
express.json(),
openapiValidatorMiddleware({
openApiValidatorMiddleware({
apiSpec: openApiSpecPath,
operationHandlers: handlersDirectory,
validateRequests: true,
Expand Down

0 comments on commit cc37a50

Please sign in to comment.