Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix typescript error #521

Merged
merged 2 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/behavior-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ export class BehaviorRouter {
res.setHeader(key as string, value);
}
}

if (response.bodyEncoding === 'base64') {
res.end(Buffer.from(response.body, 'base64').toString('utf-8'));
res.end(Buffer.from(response.body ?? '', 'base64').toString('utf-8'));
} else {
res.end(response.body);
}
Expand Down
7 changes: 4 additions & 3 deletions src/services/origin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as fs from 'fs-extra';
import * as http from 'http';
import * as https from 'https';
import * as path from 'path';

import { parse } from 'url';

import { toHttpHeaders } from '../utils';
import { OutgoingHttpHeaders } from 'http';
import { InternalServerError, NotFoundError } from '../errors/http';
Expand All @@ -15,8 +15,6 @@ export class Origin {
private readonly type: 'http' | 'https' | 'file' | 'noop' = 'http';

constructor(public readonly baseUrl: string = '') {
const regex = /^https?:\/\//;

if (!baseUrl) {
this.type = 'noop';
} else if (/^http:\/\//.test(baseUrl)) {
Expand Down Expand Up @@ -50,6 +48,7 @@ export class Origin {
// Make sure error gets back to user
const status = err.statusCode || StatusCodes.INTERNAL_SERVER_ERROR;
const reasonPhrase = err.reasonPhrase || 'Internal Server Error';

return {
status: status,
statusDescription: reasonPhrase,
Expand Down Expand Up @@ -144,9 +143,11 @@ export class Origin {
});
res.on('error', (err: Error) => reject(err));
});

if (request.body && request.body.data) {
req.write(request.body.data);
}

req.end();
});
}
Expand Down