Merge pull request #1450 from valadaptive/express-common

Move parsers into shared "express-common" module
This commit is contained in:
Cohee 2023-12-04 19:28:55 +02:00 committed by GitHub
commit 414c9bd5fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -50,6 +50,7 @@ util.inspect.defaultOptions.maxStringLength = null;
// local library imports
const basicAuthMiddleware = require('./src/middleware/basicAuthMiddleware');
const { jsonParser, urlencodedParser } = require('./src/express-common.js');
const characterCardParser = require('./src/character-card-parser.js');
const contentManager = require('./src/endpoints/content-manager');
const statsHelpers = require('./statsHelpers.js');
@ -215,8 +216,6 @@ var chatsPath = 'public/chats/';
const SETTINGS_FILE = './public/settings.json';
const AVATAR_WIDTH = 400;
const AVATAR_HEIGHT = 600;
const jsonParser = express.json({ limit: '200mb' });
const urlencodedParser = express.urlencoded({ extended: true, limit: '200mb' });
const { DIRECTORIES, UPLOADS_PATH, PALM_SAFETY, TEXTGEN_TYPES, CHAT_COMPLETION_SOURCES } = require('./src/constants');
const { TavernCardValidator } = require('./src/validator/TavernCardValidator');

7
src/express-common.js Normal file
View File

@ -0,0 +1,7 @@
const express = require('express');
// Instantiate parser middleware here with application-level size limits
const jsonParser = express.json({ limit: '200mb' });
const urlencodedParser = express.urlencoded({ extended: true, limit: '200mb' });
module.exports = { jsonParser, urlencodedParser };