CommunitySolidServer/src/pods/generate/StaticFolderGenerator.ts
2022-10-06 09:36:04 +02:00

22 lines
951 B
TypeScript

import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
import type { Resource, ResourcesGenerator } from './ResourcesGenerator';
import type { TemplatedResourcesGenerator } from './TemplatedResourcesGenerator';
import Dict = NodeJS.Dict;
/**
* Stores a static template folder that will be used to call the wrapped {@link TemplatedResourcesGenerator}.
*/
export class StaticFolderGenerator implements ResourcesGenerator {
private readonly resourcesGenerator: TemplatedResourcesGenerator;
private readonly templateFolder: string;
public constructor(resourcesGenerator: TemplatedResourcesGenerator, templateFolder: string) {
this.resourcesGenerator = resourcesGenerator;
this.templateFolder = templateFolder;
}
public generate(location: ResourceIdentifier, options: Dict<string>): AsyncIterable<Resource> {
return this.resourcesGenerator.generate(this.templateFolder, location, options);
}
}