Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { RolesGuard } from './auth/roles.guard'; import { Reflector } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import * as fs from 'fs'; import * as path from 'path'; import { ValidationPipe } from '@nestjs/common'; async function bootstrap() { const app = await NestFactory.create<NestExpressApplication>(AppModule); app.useGlobalPipes( new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true, }), ); // Serve static files app.useStaticAssets(path.join(__dirname, 'uploads'), { prefix: '/uploads/', }); // Tambahkan global guard (opsional) const reflector = app.get(Reflector); app.useGlobalGuards(new RolesGuard(reflector)); // Pastikan folder uploads/profile ada const uploadDir = path.join(__dirname, 'uploads', 'profile'); Iif (!fs.existsSync(uploadDir)) { fs.mkdirSync(uploadDir, { recursive: true }); } await app.listen(process.env.PORT ?? 3000); } bootstrap(); |