Skip to content

Commit

Permalink
feat: add constructor options to configure max sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Aug 8, 2024
1 parent 98405f0 commit c98a522
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ import * as utils from './utils.js';
* @property {import('@eik/sink').default} [sink]
* @property {import('pino').Logger} [logger]
* @property {import('@eik/sink').default} [customSink] [Deprecated] Use sink instead
* @property {number} [aliasCacheControl]
* @property {string} [aliasCacheControl]
* @property {string} [notFoundCacheControl="public, max-age=5"]
* @property {number} [pkgMaxFileSize=10000000] The limit in bytes before PUT /pkg/ starts returning 413 Content Too Large
* @property {number} [mapMaxFileSize=1000000] The limit in bytes before PUT /map/ starts returning 413 Content Too Large
*/

const EikService = class EikService {
Expand All @@ -26,7 +29,13 @@ const EikService = class EikService {
*/
constructor(options = {}) {
let { sink, logger } = options;
const { customSink, notFoundCacheControl, aliasCacheControl } = options;
const {
customSink,
notFoundCacheControl,
aliasCacheControl,
pkgMaxFileSize,
mapMaxFileSize,
} = options;
this._notFoundCacheControl =
notFoundCacheControl || 'public, max-age=5';

Expand Down Expand Up @@ -90,9 +99,19 @@ const EikService = class EikService {
});
this._pkgLog = new eik.http.PkgLog({ organizations, sink, logger });
this._pkgGet = new eik.http.PkgGet({ organizations, sink, logger });
this._pkgPut = new eik.http.PkgPut({ organizations, sink, logger });
this._pkgPut = new eik.http.PkgPut({
organizations,
sink,
logger,
pkgMaxFileSize,
});
this._mapGet = new eik.http.MapGet({ organizations, sink, logger });
this._mapPut = new eik.http.MapPut({ organizations, sink, logger });
this._mapPut = new eik.http.MapPut({
organizations,
sink,
logger,
mapMaxFileSize,
});

const mergeStreams = (...streams) => {
const str = new PassThrough({ objectMode: true });
Expand Down

0 comments on commit c98a522

Please sign in to comment.