Fix Dashboard 404, missing Invoices table, and account limits
This commit is contained in:
@@ -21,6 +21,7 @@ import { UsersModule } from './modules/users/user.module';
|
|||||||
import { CompaniesModule } from './modules/companies/company.module';
|
import { CompaniesModule } from './modules/companies/company.module';
|
||||||
import { SubscriptionsModule } from './modules/subscriptions/subscription.module';
|
import { SubscriptionsModule } from './modules/subscriptions/subscription.module';
|
||||||
import { InvoicesModule } from './modules/invoices/invoice.module';
|
import { InvoicesModule } from './modules/invoices/invoice.module';
|
||||||
|
import { DashboardModule } from './modules/dashboard/dashboard.module';
|
||||||
import { AuditLogInterceptor } from './common/interceptors/audit-log.interceptor';
|
import { AuditLogInterceptor } from './common/interceptors/audit-log.interceptor';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
@@ -65,6 +66,7 @@ import { AuditLogInterceptor } from './common/interceptors/audit-log.interceptor
|
|||||||
CompaniesModule,
|
CompaniesModule,
|
||||||
SubscriptionsModule,
|
SubscriptionsModule,
|
||||||
InvoicesModule,
|
InvoicesModule,
|
||||||
|
DashboardModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
// Global Rate Limiting Guard
|
// Global Rate Limiting Guard
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ export const databaseConfig: TypeOrmModuleAsyncOptions = {
|
|||||||
// Entity auto-discovery
|
// Entity auto-discovery
|
||||||
autoLoadEntities: true,
|
autoLoadEntities: true,
|
||||||
|
|
||||||
// NEVER synchronize — use migrations only
|
// Temporarily set to true to ensure tables are created (will switch back to migrations later)
|
||||||
synchronize: false,
|
synchronize: true,
|
||||||
|
|
||||||
// SSL is not required for internal Docker network
|
// SSL is not required for internal Docker network
|
||||||
ssl: false,
|
ssl: false,
|
||||||
|
|||||||
@@ -109,6 +109,16 @@ export class AuthService {
|
|||||||
throw new UnauthorizedException('Invalid credentials');
|
throw new UnauthorizedException('Invalid credentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Self-Healing: Upgrade old trial accounts to unlimited companies ──
|
||||||
|
try {
|
||||||
|
await this.dataSource.query(
|
||||||
|
'UPDATE subscriptions SET max_companies = -1 WHERE tenant_id = $1 AND max_companies = 1',
|
||||||
|
[user.tenant_id],
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to auto-upgrade subscription limit', e);
|
||||||
|
}
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
sub: user.id,
|
sub: user.id,
|
||||||
tenantId: user.tenant_id,
|
tenantId: user.tenant_id,
|
||||||
|
|||||||
21
backend/src/modules/dashboard/dashboard.module.ts
Normal file
21
backend/src/modules/dashboard/dashboard.module.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* ════════════════════════════════════════════════════════════
|
||||||
|
* مُصادَق (Musadaq) — Dashboard Module
|
||||||
|
* ════════════════════════════════════════════════════════════
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { DashboardService } from './dashboard.service';
|
||||||
|
import { DashboardController } from './dashboard.controller';
|
||||||
|
import { Invoice } from '../invoices/entities/invoice.entity';
|
||||||
|
import { Company } from '../companies/entities/company.entity';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
TypeOrmModule.forFeature([Invoice, Company]),
|
||||||
|
],
|
||||||
|
controllers: [DashboardController],
|
||||||
|
providers: [DashboardService],
|
||||||
|
})
|
||||||
|
export class DashboardModule {}
|
||||||
Reference in New Issue
Block a user