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')
@Controller('admin')
export class AdminController {
constructor(private readonly adminService: AdminService) { }
constructor(private readonly adminService: AdminService) {}
@Get('stats') @ApiOperation({ summary: 'Get dashboard stats' })
async getDashboardStats() { return this.adminService.getDashboardStats(); }
@Get('stats')
@ApiOperation({ summary: 'Get dashboard stats' })
getDashboardStats() {
return this.adminService.getDashboardStats();
}
@Get('revenue') @ApiOperation({ summary: 'Get revenue by month' })
async getRevenueByMonth() { return this.adminService.getRevenueByMonth(); }
@Get('revenue')
@ApiOperation({ summary: 'Get revenue by month' })
getRevenueByMonth() {
return this.adminService.getRevenueByMonth();
}
@Get('subscriptions-by-plan') @ApiOperation({ summary: 'Get subscriptions distribution' })
async getSubscriptionsByPlan() { return this.adminService.getSubscriptionsByPlan(); }
@Get('subscriptions-by-plan')
@ApiOperation({ summary: 'Get subscriptions distribution' })
getSubscriptionsByPlan() {
return this.adminService.getSubscriptionsByPlan();
}
}

View file

@ -2,21 +2,34 @@ import { Injectable } from '@nestjs/common';
@Injectable()
export class AdminService {
async getDashboardStats() {
return {
totalCompanies: 30, totalUsers: 1250, totalJobs: 990, totalApplications: 3500,
activeSubscriptions: 25, monthlyRevenue: 12500, recentSignups: 45, conversionRate: 8.5,
};
}
getDashboardStats() {
return {
totalCompanies: 30,
totalUsers: 1250,
totalJobs: 990,
totalApplications: 3500,
activeSubscriptions: 25,
monthlyRevenue: 12500,
recentSignups: 45,
conversionRate: 8.5,
};
}
async getRevenueByMonth() {
return [
{ month: 'Jan', revenue: 8500 }, { month: 'Feb', revenue: 9200 },
{ month: 'Mar', revenue: 10100 }, { month: 'Apr', revenue: 11500 }, { month: 'May', revenue: 12500 },
];
}
getRevenueByMonth() {
return [
{ month: 'Jan', revenue: 8500 },
{ month: 'Feb', revenue: 9200 },
{ month: 'Mar', revenue: 10100 },
{ month: 'Apr', revenue: 11500 },
{ month: 'May', revenue: 12500 },
];
}
async getSubscriptionsByPlan() {
return [{ plan: 'Starter', count: 10 }, { plan: 'Professional', count: 12 }, { plan: 'Enterprise', count: 3 }];
}
getSubscriptionsByPlan() {
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() {
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 }));
const config = new DocumentBuilder()
.setTitle('GoHorse Backoffice API')
.setDescription('SaaS Administration and Subscription Management')
.setVersion('1.0')
.addTag('Stripe').addTag('Plans').addTag('Admin Dashboard')
.addTag('Stripe')
.addTag('Plans')
.addTag('Admin Dashboard')
.addBearerAuth()
.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;
await app.listen(port);
console.log(`🚀 Backoffice API: http://localhost:${port}`);
console.log(`📚 Swagger docs: http://localhost:${port}/api/docs`);
}
bootstrap();
void bootstrap();