fix git
This commit is contained in:
16
storage_server/src/app.module.ts
Normal file
16
storage_server/src/app.module.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ServeStaticModule } from '@nestjs/serve-static';
|
||||
import { join } from 'path';
|
||||
|
||||
// Resolve the storage directory (default to ../storage relative to the compiled or source path)
|
||||
const storageDir = process.env.STORAGE_DIR || join(__dirname, '..', '..', 'storage');
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ServeStaticModule.forRoot({
|
||||
rootPath: storageDir,
|
||||
serveRoot: '/',
|
||||
}),
|
||||
],
|
||||
})
|
||||
export class AppModule { }
|
||||
25
storage_server/src/main.ts
Normal file
25
storage_server/src/main.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { join } from 'path';
|
||||
|
||||
async function bootstrap() {
|
||||
const logger = new Logger('Bootstrap');
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
// Enable CORS for static file downloading/fetching across origins
|
||||
app.enableCors({
|
||||
origin: '*',
|
||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
const port = process.env.PORT ?? 8081;
|
||||
const storageDir = process.env.STORAGE_DIR || join(__dirname, '..', '..', 'storage');
|
||||
|
||||
await app.listen(port);
|
||||
|
||||
logger.log(`Storage static file server is running on: http://localhost:${port}`);
|
||||
logger.log(`Serving static files from: ${storageDir}`);
|
||||
}
|
||||
bootstrap();
|
||||
Reference in New Issue
Block a user