Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

update for webpack 4 #23

Merged
merged 4 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add missing files
  • Loading branch information
codeBelt committed Nov 15, 2018
commit ef85b17063e1f4d87b5bc55847cea5f00ab8ff05
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "typescript-hapi-react-hot-loader-example",
"version": "1.0.0",
"version": "2.0.0",
"description": "Simple React Hot Loading example with Hapi Server-side rendering",
"engines": {
"node": ">=8.9.1"
"node": ">=10.11.0"
},
"scripts": {
"---------- HELPERS -----------------------------------------------------------------------------": "",
Expand Down
5 changes: 5 additions & 0 deletions src/constants/KeyboardKeyEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum KeyboardKeyEnum {
ESCAPE = 'Escape',
}

export default KeyboardKeyEnum;
9 changes: 9 additions & 0 deletions src/constants/RequestMethodEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
enum RequestMethodEnum {
GET = 'GET',
POST = 'POST',
PUT = 'PUT',
PATCH = 'PATCH',
DELETE = 'DELETE',
}

export default RequestMethodEnum;
4 changes: 2 additions & 2 deletions src/server/ServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class ServerManager {
}

public async startServer(): Promise<void> {
process.on('unhandledRejection', (err) => {
console.error(err);
process.on('unhandledRejection', (error: Error) => {
console.error(error);
process.exit(1);
});

Expand Down
42 changes: 42 additions & 0 deletions src/server/utilities/ServerUtility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as Hapi from 'hapi';
import * as url from 'url';
import * as path from 'path';
import * as util from 'util';
import * as fs from 'fs';

const readFileAsync = util.promisify(fs.readFile);

export interface IServerLocation extends url.Url {
host: string;
hostname: string;
href: string;
origin: string;
pathname: string;
protocol: string;
length: number;
}

export default class ServerUtility {

public static createLocationObject(request: Hapi.Request): IServerLocation {
const protocol: string = request.headers['x-forwarded-proto'] || request.server.info.protocol;

return {
...request.url,
host: request.info.host,
hostname: request.info.host.split(':')[0],
href: `${protocol}://${request.info.host}${request.url.path}`,
origin: `${protocol}://${request.info.host}`,
pathname: request.url.path.split('?')[0],
protocol: `${protocol}:`,
length: null,
};
}

public static async loadHtmlFile(): Promise<string> {
const htmlPath = path.resolve(__dirname, '../../public/index.html');

return readFileAsync(htmlPath, 'utf8');
}

}
4 changes: 4 additions & 0 deletions src/stores/meta/models/ITitleDescription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default interface ITitleDescription {
readonly description?: string;
readonly title: string;
}