MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / constructor

Method constructor

packages/server/src/api/rest/index.ts:280–305  ·  view source on GitHub ↗
(private readonly options: RestApiHandlerOptions<Schema>)

Source from the content-addressed store, hash-verified

278 private nestedRoutes: boolean;
279
280 constructor(private readonly options: RestApiHandlerOptions<Schema>) {
281 this.validateOptions(options);
282
283 this.idDivider = options.idDivider ?? DEFAULT_ID_DIVIDER;
284 const segmentCharset = options.urlSegmentCharset ?? 'a-zA-Z0-9-_~ %';
285
286 this.modelNameMapping = options.modelNameMapping ?? {};
287 this.modelNameMapping = Object.fromEntries(
288 Object.entries(this.modelNameMapping).map(([k, v]) => [lowerCaseFirst(k), v]),
289 );
290 this.reverseModelNameMapping = Object.fromEntries(
291 Object.entries(this.modelNameMapping).map(([k, v]) => [v, k]),
292 );
293
294 this.externalIdMapping = options.externalIdMapping ?? {};
295 this.externalIdMapping = Object.fromEntries(
296 Object.entries(this.externalIdMapping).map(([k, v]) => [lowerCaseFirst(k), v]),
297 );
298
299 this.nestedRoutes = options.nestedRoutes ?? false;
300
301 this.urlPatternMap = this.buildUrlPatternMap(segmentCharset);
302
303 this.buildTypeMap();
304 this.buildSerializers();
305 }
306
307 private validateOptions(options: RestApiHandlerOptions<Schema>) {
308 const schema = z.strictObject({

Callers

nothing calls this directly

Calls 5

validateOptionsMethod · 0.95
buildUrlPatternMapMethod · 0.95
buildTypeMapMethod · 0.95
buildSerializersMethod · 0.95
lowerCaseFirstFunction · 0.90

Tested by

no test coverage detected