|
@@ -4,6 +4,7 @@ import {
|
|
|
AssetStorageStrategy,
|
|
AssetStorageStrategy,
|
|
|
Logger,
|
|
Logger,
|
|
|
PluginCommonModule,
|
|
PluginCommonModule,
|
|
|
|
|
+ ProcessContext,
|
|
|
registerPluginStartupMessage,
|
|
registerPluginStartupMessage,
|
|
|
RuntimeVendureConfig,
|
|
RuntimeVendureConfig,
|
|
|
VendurePlugin,
|
|
VendurePlugin,
|
|
@@ -159,8 +160,13 @@ export class AssetServerPlugin implements NestModule, OnApplicationBootstrap {
|
|
|
return config;
|
|
return config;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ constructor(private processContext: ProcessContext) {}
|
|
|
|
|
+
|
|
|
/** @internal */
|
|
/** @internal */
|
|
|
onApplicationBootstrap(): void | Promise<void> {
|
|
onApplicationBootstrap(): void | Promise<void> {
|
|
|
|
|
+ if (this.processContext.isWorker) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (AssetServerPlugin.options.presets) {
|
|
if (AssetServerPlugin.options.presets) {
|
|
|
for (const preset of AssetServerPlugin.options.presets) {
|
|
for (const preset of AssetServerPlugin.options.presets) {
|
|
|
const existingIndex = this.presets.findIndex(p => p.name === preset.name);
|
|
const existingIndex = this.presets.findIndex(p => p.name === preset.name);
|
|
@@ -177,6 +183,9 @@ export class AssetServerPlugin implements NestModule, OnApplicationBootstrap {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
configure(consumer: MiddlewareConsumer) {
|
|
configure(consumer: MiddlewareConsumer) {
|
|
|
|
|
+ if (this.processContext.isWorker) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
Logger.info('Creating asset server middleware', loggerCtx);
|
|
Logger.info('Creating asset server middleware', loggerCtx);
|
|
|
consumer.apply(this.createAssetServer()).forRoutes(AssetServerPlugin.options.route);
|
|
consumer.apply(this.createAssetServer()).forRoutes(AssetServerPlugin.options.route);
|
|
|
registerPluginStartupMessage('Asset server', AssetServerPlugin.options.route);
|
|
registerPluginStartupMessage('Asset server', AssetServerPlugin.options.route);
|