26 lines
786 B
TypeScript
26 lines
786 B
TypeScript
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();
|