fix(backoffice): resolve eslint errors (async/await usage and floating promises)

This commit is contained in:
Tiago Yamamoto 2025-12-15 10:35:15 -03:00
parent d3d6ae2991
commit 5c45557537
3 changed files with 57 additions and 26 deletions

View file

@ -5,14 +5,23 @@ import { AdminService } from './admin.service';
@ApiTags('Admin Dashboard') @ApiTags('Admin Dashboard')
@Controller('admin') @Controller('admin')
export class AdminController { export class AdminController {
constructor(private readonly adminService: AdminService) { } constructor(private readonly adminService: AdminService) {}
@Get('stats') @ApiOperation({ summary: 'Get dashboard stats' }) @Get('stats')
async getDashboardStats() { return this.adminService.getDashboardStats(); } @ApiOperation({ summary: 'Get dashboard stats' })
getDashboardStats() {
return this.adminService.getDashboardStats();
}
@Get('revenue') @ApiOperation({ summary: 'Get revenue by month' }) @Get('revenue')
async getRevenueByMonth() { return this.adminService.getRevenueByMonth(); } @ApiOperation({ summary: 'Get revenue by month' })
getRevenueByMonth() {
return this.adminService.getRevenueByMonth();
}
@Get('subscriptions-by-plan') @ApiOperation({ summary: 'Get subscriptions distribution' }) @Get('subscriptions-by-plan')
async getSubscriptionsByPlan() { return this.adminService.getSubscriptionsByPlan(); } @ApiOperation({ summary: 'Get subscriptions distribution' })
getSubscriptionsByPlan() {
return this.adminService.getSubscriptionsByPlan();
}
} }

View file

@ -2,21 +2,34 @@ import { Injectable } from '@nestjs/common';
@Injectable() @Injectable()
export class AdminService { export class AdminService {
async getDashboardStats() { getDashboardStats() {
return { return {
totalCompanies: 30, totalUsers: 1250, totalJobs: 990, totalApplications: 3500, totalCompanies: 30,
activeSubscriptions: 25, monthlyRevenue: 12500, recentSignups: 45, conversionRate: 8.5, totalUsers: 1250,
}; totalJobs: 990,
} totalApplications: 3500,
activeSubscriptions: 25,
monthlyRevenue: 12500,
recentSignups: 45,
conversionRate: 8.5,
};
}
async getRevenueByMonth() { getRevenueByMonth() {
return [ return [
{ month: 'Jan', revenue: 8500 }, { month: 'Feb', revenue: 9200 }, { month: 'Jan', revenue: 8500 },
{ month: 'Mar', revenue: 10100 }, { month: 'Apr', revenue: 11500 }, { month: 'May', revenue: 12500 }, { month: 'Feb', revenue: 9200 },
]; { month: 'Mar', revenue: 10100 },
} { month: 'Apr', revenue: 11500 },
{ month: 'May', revenue: 12500 },
];
}
async getSubscriptionsByPlan() { getSubscriptionsByPlan() {
return [{ plan: 'Starter', count: 10 }, { plan: 'Professional', count: 12 }, { plan: 'Enterprise', count: 3 }]; return [
} { plan: 'Starter', count: 10 },
{ plan: 'Professional', count: 12 },
{ plan: 'Enterprise', count: 3 },
];
}
} }

View file

@ -6,21 +6,30 @@ import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule, { rawBody: true }); const app = await NestFactory.create(AppModule, { rawBody: true });
app.enableCors({ origin: ['http://localhost:3000', 'https://gohorsejobs.com'], credentials: true }); app.enableCors({
origin: ['http://localhost:3000', 'https://gohorsejobs.com'],
credentials: true,
});
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
const config = new DocumentBuilder() const config = new DocumentBuilder()
.setTitle('GoHorse Backoffice API') .setTitle('GoHorse Backoffice API')
.setDescription('SaaS Administration and Subscription Management') .setDescription('SaaS Administration and Subscription Management')
.setVersion('1.0') .setVersion('1.0')
.addTag('Stripe').addTag('Plans').addTag('Admin Dashboard') .addTag('Stripe')
.addTag('Plans')
.addTag('Admin Dashboard')
.addBearerAuth() .addBearerAuth()
.build(); .build();
SwaggerModule.setup('api/docs', app, SwaggerModule.createDocument(app, config)); SwaggerModule.setup(
'api/docs',
app,
SwaggerModule.createDocument(app, config),
);
const port = process.env.PORT || 3001; const port = process.env.PORT || 3001;
await app.listen(port); await app.listen(port);
console.log(`🚀 Backoffice API: http://localhost:${port}`); console.log(`🚀 Backoffice API: http://localhost:${port}`);
console.log(`📚 Swagger docs: http://localhost:${port}/api/docs`); console.log(`📚 Swagger docs: http://localhost:${port}/api/docs`);
} }
bootstrap(); void bootstrap();