Skip to content

Commit

Permalink
Merge pull request #4 from emanguy/develop
Browse files Browse the repository at this point in the history
Add license
  • Loading branch information
emanguy authored Feb 3, 2019
2 parents 74780c8 + ad44457 commit 6cd2533
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 24 deletions.
26 changes: 21 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
FROM node:8-alpine
FROM node:8-alpine as buildContainer

RUN mkdir -p /srv/
WORKDIR /srv/

ADD types ./types
ADD package.json yarn.lock tsconfig.json ./
ADD src ./src
COPY types ./types
COPY package.json yarn.lock tsconfig.json ./
COPY src ./src
ENV NODE_ENV=production

RUN yarn install && \
yarn run build
CMD yarn run start

######################

FROM node:8-alpine

RUN mkdir -p /srv/
WORKDIR /srv/
COPY --from=buildContainer /srv/build/ /srv/build/
COPY --from=buildContainer /srv/node_modules/ /srv/node_modules/
ENV NODE_ENV=production
EXPOSE 80

CMD node build/index.js
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2019, Evan Rittenhouse
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sending those events to connected clients.
* `PROCESS_PORT` - the port to serve the node server on
* `REDIS_URL` - The connection URL to the redis server which pushes quest update events
* `REDIS_PASSWORD` - The password for the redis server we're connecting to
* `NODE_ENV` - Standard node environment variable.

## Local testing

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
"test": "mocha -r ts-node/register test/**/*.ts"
},
"dependencies": {
"@types/cors": "^2.8.4",
"@types/dotenv": "^4.0.3",
"@types/express": "^4.11.1",
"@types/morgan": "^1.7.35",
"@types/redis": "^2.8.6",
"@types/uuid": "^3.4.3",
"@types/winston": "^2.3.9",
"body-parser": "^1.18.3",
"common-interfaces": "github:emanguy/QuestTracker-CommonInterfaces#1.1.0",
"common-interfaces": "github:emanguy/QuestTracker-CommonInterfaces#1.2.1",
"cors": "^2.8.5",
"dotenv": "^5.0.1",
"express": "^4.16.3",
"morgan": "^1.9.0",
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ dotenv.config();
export interface Configuration {
applicationPort: string | number
redisUrl: string
environment: string
redisPassword?: string
}
const config = {
applicationPort: process.env["PROCESS_PORT"] || 80,
redisUrl: process.env["REDIS_URL"] || "redis://localhost:6379",
environment: process.env["NODE_ENV"] || "development",
redisPassword: process.env["REDIS_PASSWORD"]
};

Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import {Response} from "express";
import * as morgan from "morgan";
import log from "./logger";
import config from "./config";
import cors from "./middleware/cors";
import addLoggingInfo from "./middleware/logging-metadata";
import jsonParse from "./middleware/json-parse";
import PushServiceClientController from "./controllers/ClientController";
import * as cors from "cors";

const app = express();

app.use(cors);
if (config.environment !== "production") {
app.use(cors());
}
app.use(morgan("common"));
app.use(jsonParse);
app.use(addLoggingInfo);
Expand Down
6 changes: 0 additions & 6 deletions src/middleware/cors.ts

This file was deleted.

1 change: 1 addition & 0 deletions test/services/RedisUpdaterServiceTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ suite("Redis updater service test", () => {
const config:Configuration = {
applicationPort: 3000,
redisUrl: "redis://localhost:6379",
environment: "testing",
redisPassword: "testRedis"
};
const DOCKER_STARTUP_TIME = 5000;
Expand Down
31 changes: 21 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
dependencies:
"@types/node" "*"

"@types/cors@^2.8.4":
version "2.8.4"
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.4.tgz#50991a759a29c0b89492751008c6af7a7c8267b0"
dependencies:
"@types/express" "*"

"@types/dockerode@^2.5.4":
version "2.5.4"
resolved "https://registry.yarnpkg.com/@types/dockerode/-/dockerode-2.5.4.tgz#b568661690e49d444dd4427e70308406a5993f42"
Expand Down Expand Up @@ -298,15 +304,9 @@ [email protected]:
version "2.15.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"

"common-interfaces@github:emanguy/QuestTracker-CommonInterfaces#1.0.1":
version "1.0.1"
resolved "https://codeload.github.com/emanguy/QuestTracker-CommonInterfaces/tar.gz/457cb02d3da7eba057bfbd61597236cab346595d"
dependencies:
typescript "^3.1.1"

"common-interfaces@github:emanguy/QuestTracker-CommonInterfaces#1.1.0":
version "1.1.0"
resolved "https://codeload.github.com/emanguy/QuestTracker-CommonInterfaces/tar.gz/084ce4aeb17331f24eb14659aa4e8fb1138c3064"
"common-interfaces@github:emanguy/QuestTracker-CommonInterfaces#1.2.1":
version "1.2.1"
resolved "https://codeload.github.com/emanguy/QuestTracker-CommonInterfaces/tar.gz/af618b493986efa0f9dabe2a717ed5e08862f25d"
dependencies:
typescript "^3.1.1"

Expand Down Expand Up @@ -342,6 +342,13 @@ core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"

cors@^2.8.5:
version "2.8.5"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
dependencies:
object-assign "^4"
vary "^1"

[email protected]:
version "0.7.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39"
Expand Down Expand Up @@ -726,6 +733,10 @@ [email protected]:
version "0.6.1"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"

object-assign@^4:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

on-finished@~2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"
Expand Down Expand Up @@ -1059,7 +1070,7 @@ uuid@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"

[email protected], vary@~1.1.2:
[email protected], vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"

Expand Down

0 comments on commit 6cd2533

Please sign in to comment.