Skip to content

Commit

Permalink
feat: internationalization (#21)
Browse files Browse the repository at this point in the history
* refactor: added all enums for errors exception keys

* refactor: modified exception filter
  • Loading branch information
KostaD02 authored Sep 9, 2023
1 parent 640bc41 commit fb16566
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { ExceptionService } from './shared';
import { ApiTags } from '@nestjs/swagger';
import {
AuthExpectionKeys,
CartExpectionKeys,
GlobalExceptionKeys,
ProductExceptionKeys,
ExceptionStatusKeys,
} from 'src/enums';

@ApiTags('root')
@Controller()
Expand All @@ -18,6 +25,12 @@ export class AppController {

@Get('lang/errors')
getErrors() {
return this.exceptionService.statusKeys;
return Object.values({
...ExceptionStatusKeys,
...GlobalExceptionKeys,
...ProductExceptionKeys,
...AuthExpectionKeys,
...CartExpectionKeys,
});
}
}
1 change: 1 addition & 0 deletions src/http-exceptions.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class HttpExceptionsFilter implements ExceptionFilter {
statusCode: status,
timestamp: new Date().toISOString(),
path: request.url,
help: `if you think this error should not happen, please create new issue at: https://github.com/educata/everrest/issues`,
});
}
}

0 comments on commit fb16566

Please sign in to comment.