Skip to content

Commit daa36e2

Browse files
rename folder. remove getType method
1 parent 1f26fde commit daa36e2

File tree

7 files changed

+11
-25
lines changed

7 files changed

+11
-25
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/rocket-webhook-core/src/response/responder/webhook-empty-response.ts renamed to packages/rocket-webhook-core/src/response/responses/webhook-empty-response.ts

File renamed without changes.

packages/rocket-webhook-core/src/response/responder/webhook-file-response.ts renamed to packages/rocket-webhook-core/src/response/responses/webhook-file-response.ts

File renamed without changes.

packages/rocket-webhook-core/src/response/responder/webhook-json-response.ts renamed to packages/rocket-webhook-core/src/response/responses/webhook-json-response.ts

File renamed without changes.

packages/rocket-webhook-core/src/response/responder/webhook-text-response.ts renamed to packages/rocket-webhook-core/src/response/responses/webhook-text-response.ts

File renamed without changes.

packages/rocket-webhook-core/src/response/webhook-response-builder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Headers, WebhookHandlerReturnType, WebhookResponseType } from '@boostercloud/rocket-webhook-types'
2-
import { WebhookFileResponse } from './responder/webhook-file-response'
3-
import { WebhookJsonResponse } from './responder/webhook-json-response'
4-
import { WebhookTextResponse } from './responder/webhook-text-response'
5-
import { WebhookEmptyResponse } from './responder/webhook-empty-response'
2+
import { WebhookFileResponse } from './responses/webhook-file-response'
3+
import { WebhookJsonResponse } from './responses/webhook-json-response'
4+
import { WebhookTextResponse } from './responses/webhook-text-response'
5+
import { WebhookEmptyResponse } from './responses/webhook-empty-response'
66

77
export interface WebhookResponseClass {
88
getBody(response?: WebhookHandlerReturnType): unknown

packages/rocket-webhook-local-infrastructure/src/controllers/webhook-controller.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { requestFailed } from '../http'
44
import { rocketFunctionIDEnvVar } from '@boostercloud/framework-types'
55
import {
66
functionID,
7-
Headers,
87
HttpSuccessStatusCode,
98
WebhookAPIResult,
109
WebhookAPISuccessResult,
@@ -30,7 +29,7 @@ export class WebhookController {
3029
if (this.isSuccess(response)) {
3130
const body = response.body
3231
this.setHeaders(response, res)
33-
const type = this.getType(response?.headers)
32+
const type = response?.headers['Content-type']
3433
if (type === WebhookResponseType.file) {
3534
const readStream = new stream.PassThrough()
3635
readStream.end(response.body)
@@ -50,19 +49,6 @@ export class WebhookController {
5049
}
5150
}
5251

53-
private getType(headers: Headers): WebhookResponseType {
54-
const contentType = headers['Content-type']
55-
56-
switch (contentType) {
57-
case WebhookResponseType.json:
58-
return WebhookResponseType.json
59-
case WebhookResponseType.text:
60-
return WebhookResponseType.text
61-
default:
62-
return WebhookResponseType.file
63-
}
64-
}
65-
6652
private setHeaders(response: WebhookAPISuccessResult, res: express.Response): void {
6753
for (const headersKey in response.headers) {
6854
res.setHeader(headersKey, response.headers[headersKey])

0 commit comments

Comments
 (0)