From 5767e845e1dbfd5e9a22bab80c96e57404d0e243 Mon Sep 17 00:00:00 2001 From: Dmitry Medvedev Date: Fri, 19 Apr 2019 03:18:09 +0000 Subject: [PATCH] feat: use PORT env variable if provided instead of default (8080) --- README.md | 4 +++- src/plot.ts | 6 +++--- test/server.spec.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3d73e92..42ec83f 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,8 @@ pending plots are opened in a unique tab and all the data is requested, the server shuts down. If you fire another plot the server starts again provides your plot and shuts down automatically. +Another port can be provided via PORT environment variable. + ## Contributing Contributions in all forms are welcome. @@ -192,4 +194,4 @@ the [website](https://felixlemke.com). ## Dependencies -- [opn](https://www.npmjs.com/package/opn) \ No newline at end of file +- [opn](https://www.npmjs.com/package/opn) diff --git a/src/plot.ts b/src/plot.ts index 8789e91..ba430be 100644 --- a/src/plot.ts +++ b/src/plot.ts @@ -2,8 +2,8 @@ import { IPlot, IPlotsContainer } from './models/index'; import { Layout, Plot } from './models/index'; import { Server } from './server'; - -const server = new Server(8080); +const port = Number(process.env.PORT) || 8080; +const server = new Server(port); export let plots: IPlot[] = []; export const plotContainer: IPlotsContainer = {}; @@ -62,4 +62,4 @@ function validate(data: Plot[], layout?: Layout) { throw new TypeError('Layout must be an object'); } } -} \ No newline at end of file +} diff --git a/test/server.spec.ts b/test/server.spec.ts index ad06c7a..b54bdea 100644 --- a/test/server.spec.ts +++ b/test/server.spec.ts @@ -2,7 +2,7 @@ import opn from 'opn'; import request from 'request'; import { Server } from '../src/server'; -const port = 8080; +const port = Number(process.env.PORT) || 8080; const validData = { opened: false, pending: false,