fix:(freight:auth): finished integrating the freight api with the freight portal

This commit is contained in:
Michael Abebe
2026-05-18 11:07:09 +03:00
parent b46a7765e8
commit 2940d20e06
3 changed files with 29 additions and 4 deletions

View File

@@ -14,6 +14,9 @@ JWT_SECRET=
JWT_ACCESS_TOKEN_SECRET=
JWT_REFRESH_TOKEN_SECRET=
JWT_EXPIRES_IN=3600
# JWT expiry for @tria-plc/api-common token utils (jsonwebtoken timespan format)
JWT_ACCESS_TOKEN_EXPIRES=1h
JWT_REFRESH_TOKEN_EXPIRES=7d
# IAM seed defaults (used by @tria-plc/iamapi-common on first boot)
SUPER_ADMIN_EMAIL=superadmin@tria.com

View File

@@ -1,7 +1,7 @@
import { Module } from "@nestjs/common";
import { Module, OnApplicationBootstrap } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { TypeOrmModule, TypeOrmModuleOptions } from "@nestjs/typeorm";
import { IamModule } from "@tria-plc/iamapi-common";
import { IamModule, DataSeeder } from "@tria-plc/iamapi-common";
import { SharedAuthModule } from "@tria-plc/api-common/modules/auth/shared-auth.module";
import appConfig from "./config/app.config";
@@ -27,7 +27,7 @@ import { NotificationsModule } from "./modules/notifications/notifications.modul
config.get<TypeOrmModuleOptions>("database")!,
}),
SharedAuthModule,
IamModule,
IamModule.forRoot(),
BookingsModule,
ConsignmentsModule,
TrainsModule,
@@ -37,4 +37,10 @@ import { NotificationsModule } from "./modules/notifications/notifications.modul
NotificationsModule,
],
})
export class AppModule {}
export class AppModule implements OnApplicationBootstrap {
constructor(private readonly seeder: DataSeeder) {}
async onApplicationBootstrap() {
await this.seeder.run();
}
}

View File

@@ -10,6 +10,7 @@ import {
BrandingProvider,
configureIam,
UserProvider,
axiosInstance,
} from "@tria-plc/iamui-common";
const queryClient = new QueryClient();
@@ -17,6 +18,21 @@ window.__IAM_CONFIG__ = {
apiUrl: `${import.meta.env.VITE_BASE_API_URL}/api`,
postLoginPath: "/",
};
// Unwrap the StandardResponse envelope ({ success, data, timestamp }) that the
// freight API's ResponseTransformInterceptor adds to every response, so that
// iamui-common can read response.data.token / response.data fields as expected.
axiosInstance.interceptors.response.use((response) => {
if (
response.data &&
typeof response.data === "object" &&
"success" in response.data &&
"data" in response.data
) {
response.data = response.data.data;
}
return response;
});
window.__USER_MANAGEMENT_BRANDING__ = {
organizationName: "EDR Platform",
appName: "EDR Portal",