Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Configuring environment variable for port, plus bugfix for #3 PR (#5)
Browse files Browse the repository at this point in the history
* added hapi-set-header dependency

this dependency adds the function to globally set an header

* setting the header Access-Control-Allow-Origin to *

* Updated Yarn lockfile

* using port from environment for containerization

* using port from environment for containerization

* bugfix

* bugfix

* bugfix

* configuring docker image-UNSTABLE
  • Loading branch information
Arcangelo Vicedomini authored and moebiusmania committed Nov 27, 2017
1 parent 7d163a2 commit 3927293
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:8-alpine
EXPOSE 8080
RUN apk update && apk add yarn
COPY /* /
RUN yarn install
CMD npm start
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "moebiusmania@gmail.com"
},
"engines": {
"node": "8.5.0"
"node": "^8.5.0"
},
"version": "1.0.0",
"main": "src/server.mjs",
Expand Down
10 changes: 7 additions & 3 deletions src/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ import status from './routes/status';
import traffic from './routes/traffic';
import Hapi from 'hapi';
import setHeader from 'hapi-set-header';
import { PORT } from './constants';
import {PORT} from './constants';

const CONF_PORT = process.env.PORT || PORT;

const server = new Hapi.Server();
setHeader(server, 'Access-Control-Allow-Origin', '*');

const ROUTES = [main, twitter, news, status, traffic];

server.connection({ port: PORT });
server.connection({ port: CONF_PORT });
setHeader(server, 'Access-Control-Allow-Origin', '*');

ROUTES.forEach( module => server.route(module) );

console.log(`Starting service at port ${PORT}`);
console.log(`Starting service at port ${CONF_PORT}`);

server.start(() => {});
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,10 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

hapi-set-header@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/hapi-set-header/-/hapi-set-header-1.0.2.tgz#2afae002c6719d6d54f3fa88462f822892d2df13"

hapi@16.5.2:
version "16.5.2"
resolved "https://registry.yarnpkg.com/hapi/-/hapi-16.5.2.tgz#d1dadf33721c6ac3aaa905ce086d9c7ffb883092"
Expand Down

0 comments on commit 3927293

Please sign in to comment.