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 = '',
): string {
return buildURL(
config.parameters.apiUrl,
config.apiPath,
`/attachment/download/${attachmentId}/${attachmentName}`,
);
}

View File

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

View File

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

View File

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

View File

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