Skip to content

Commit

Permalink
build: fix typescript error (#521)
Browse files Browse the repository at this point in the history
* build: fix typescript error

* chore: housekeeping

Co-authored-by: Matt Strom <[email protected]>
  • Loading branch information
mattstrom and Matt Strom authored Sep 19, 2022
1 parent 85c8921 commit 3390fe0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit 3390fe0

Please sign in to comment.