Refactor: adapt the api logic to use apiPath environment variable

This commit is contained in:
yassinedorbozgithub 2024-11-30 10:00:00 +01:00
parent dbc651a314
commit e8751d04a3
5 changed files with 3 additions and 7 deletions

View File

@ -91,7 +91,7 @@ export class Attachment extends BaseSchema {
attachmentName: string = '', attachmentName: string = '',
): string { ): string {
return buildURL( return buildURL(
config.parameters.apiUrl, config.apiPath,
`/attachment/download/${attachmentId}/${attachmentName}`, `/attachment/download/${attachmentId}/${attachmentName}`,
); );
} }

View File

@ -112,7 +112,6 @@ export const config: Config = {
? Number(process.env.UPLOAD_MAX_SIZE_IN_BYTES) ? Number(process.env.UPLOAD_MAX_SIZE_IN_BYTES)
: 2000000, : 2000000,
appName: 'Hexabot.ai', appName: 'Hexabot.ai',
apiUrl: 'http://localhost:4000',
appUrl: 'http://localhost:8081', appUrl: 'http://localhost:8081',
}, },
pagination: { pagination: {

View File

@ -81,7 +81,6 @@ export type Config = {
storageMode: 'disk' | 'memory'; storageMode: 'disk' | 'memory';
maxUploadSize: number; maxUploadSize: number;
appName: string; appName: string;
apiUrl: string;
appUrl: string; appUrl: string;
}; };
pagination: { pagination: {

View File

@ -49,7 +49,7 @@ export class IOMessagePipe implements PipeTransform<string, IOIncomingMessage> {
const url = message.url.startsWith('http') const url = message.url.startsWith('http')
? message.url ? message.url
: `${config.parameters.apiUrl}${message.url}`; : `${config.apiPath}${message.url}`;
if (!URL.canParse(url)) { if (!URL.canParse(url)) {
throw new BadRequestException('Cannot parse url'); throw new BadRequestException('Cannot parse url');

View File

@ -90,9 +90,7 @@ export class SocketRequest {
// Resolve the URL and path // Resolve the URL and path
const urlObj = new URL( const urlObj = new URL(
this.url.startsWith('http') this.url.startsWith('http') ? this.url : `${config.apiPath}${this.url}`,
? this.url
: `${config.parameters.apiUrl}${this.url}`,
); );
this.path = urlObj.pathname || '/'; this.path = urlObj.pathname || '/';