Browse Source

fix: temporary exception handler fix

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 1 year ago
parent
commit
ca6df1be2a
  1. 6
      packages/nocodb-nest/src/app.module.ts
  2. 3
      packages/nocodb-nest/src/filters/global-exception/global-exception.filter.ts
  3. 1
      packages/nocodb-nest/src/services/client/client.service.ts
  4. 4
      packages/nocodb-nest/tests/unit/rest/tests/auth.test.ts

6
packages/nocodb-nest/src/app.module.ts

@ -60,6 +60,9 @@ import type {
Provider,
} from '@nestjs/common';
import { ClientService } from './services/client/client.service';
import { AuthTokenStrategy } from './strategies/authtoken.strategy/authtoken.strategy';
import { BaseViewStrategy } from './strategies/base-view.strategy/base-view.strategy';
import { GoogleStrategy } from './strategies/google.strategy/google.strategy';
export const JwtStrategyProvider: Provider = {
provide: JwtStrategy,
@ -135,6 +138,9 @@ export const JwtStrategyProvider: Provider = {
LocalStrategy,
ExtractProjectIdMiddleware,
ClientService,
AuthTokenStrategy,
BaseViewStrategy,
GoogleStrategy,
],
})
export class AppModule implements OnApplicationBootstrap {

3
packages/nocodb-nest/src/filters/global-exception/global-exception.filter.ts

@ -47,7 +47,8 @@ export class GlobalExceptionFilter implements ExceptionFilter {
}
// handle different types of exceptions
if (exception instanceof HttpException) {
// todo: temporary hack, need to fix
if (exception.getStatus?.()) {
response.status(exception.getStatus()).json(exception.getResponse());
} else {
response.status(500).json({

1
packages/nocodb-nest/src/services/client/client.service.ts

@ -23,7 +23,6 @@ export class ClientService implements OnModuleInit {
private jwtStrategy: JwtStrategy,
@Inject(HttpAdapterHost) private httpAdapterHost: HttpAdapterHost,
) {
// this.server = this.httpAdapterHost.httpAdapter.getHttpServer();
}
async onModuleInit() {

4
packages/nocodb-nest/tests/unit/rest/tests/auth.test.ts

@ -56,7 +56,7 @@ function authTests() {
.expect(400);
});
it.only('Signin with valid credentials', async () => {
it('Signin with valid credentials', async () => {
const response = await request(context.app)
.post('/api/v1/auth/user/signin')
.send({
@ -73,7 +73,7 @@ function authTests() {
.post('/api/v1/auth/user/signin')
// pass empty data in await request
.send({})
.expect(400)
.expect(401)
});
it('Signin with invalid credentials', async () => {

Loading…
Cancel
Save