Skip to content

Commit

Permalink
feat: ensure RefreshTokenController returns statusCode 400 if acessTo…
Browse files Browse the repository at this point in the history
…ken is not provided
  • Loading branch information
Williancc1557 committed Jul 20, 2022
1 parent 6a2d2d3 commit 0ac818e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jest-unit-config.js
jest-integration-config.js
3 changes: 3 additions & 0 deletions jest-integration-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = require('./jest.config')
config.testMatch = ['**/*.test.ts']
module.exports = config
3 changes: 3 additions & 0 deletions jest-unit-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = require("./jest.config");
config.testMatch = ["**/*.spec.ts"];
module.exports = config;
15 changes: 15 additions & 0 deletions src/presentation/controller/refresh-token/refresh-token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Controller } from "src/presentation/protocols/controller";
import type {
HttpRequest,
HttpResponse,
} from "src/presentation/protocols/http";

export class RefreshTokenController implements Controller {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public async handle(httpRequest: HttpRequest): Promise<HttpResponse> {
return {
statusCode: 400,
body: null,
};
}
}
5 changes: 5 additions & 0 deletions src/presentation/protocols/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { HttpRequest, HttpResponse } from "./http";

export interface Controller {
handle: (httpRequest: HttpRequest) => Promise<HttpResponse>;
}
9 changes: 9 additions & 0 deletions src/presentation/protocols/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
export interface HttpRequest {
body?: any;
}

export interface HttpResponse {
statusCode: number;
body: any;
}

0 comments on commit 0ac818e

Please sign in to comment.