Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## [Unreleased]

- feat: add `limit` option to override Express' default request body size limit

## [0.4.0] - 2025-12-06
* minor: use live config values to better support VSCode extension.
* patch: make `debug` initialize lazily to pick up env vars in runtime.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ Configures global cache.
* `basePath: string` - Path to a directory to store persistent values. Default is `.global-cache`.
* `ignoreTTL: boolean` - Forces all values to be non-persistent, usefull for CI (where cross run caching is redundant). Default is `false`.
* `disabled: boolean` - Disables global cache. All values will be computed each time. Default is `false`.
* `limit: number | string` - Set the maximum allowed size in bytes of each cached value. [Default is from Express](https://expressjs.com/en/resources/middleware/body-parser.html#bodyparserjsonoptions): `'100kb'`

**Returns**: `void`

Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/client/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type GlobalCacheConfig = {
disabled?: boolean;
/* External server url */
serverUrl?: string;
/* Change the size limit for cache values (default is Express' default json limit, currently '100kb') */
limit?: number | string;
};

type GlobalConfigInternal = GlobalCacheConfig & {
Expand Down Expand Up @@ -86,6 +88,10 @@ export class GlobalConfig {
get disabled() {
return Boolean(this.config.disabled);
}

get limit() {
return this.config.limit;
}
}

function getConfigFromEnv() {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ import { router as routeGetStaleList } from './routes/get-stale-list';
import { router as routeClearTestRun } from './routes/clear';
import { errorHandler } from './error';
import { GlobalCacheServerConfig, resolveConfig, setConfig } from './config';
import { globalConfig } from '../client/config';
import { startExpressServer, stopExpressServer } from './utils/express';

export class GlobalCacheServer {
private app = express();
private server: http.Server | null = null;

constructor() {
this.app.use(express.json());
this.app.use(express.json({ limit: globalConfig.limit }));
this.app.use('/', routeRoot);
this.app.use('/', routeGet);
this.app.use('/', routeSet);
Expand Down