Skip to content

Commit 5767e84

Browse files
committed
feat: use PORT env variable if provided instead of default (8080)
1 parent 9668076 commit 5767e84

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ pending plots are opened in a unique tab and all the data is requested, the
161161
server shuts down. If you fire another plot the server starts again provides
162162
your plot and shuts down automatically.
163163

164+
Another port can be provided via PORT environment variable.
165+
164166
## Contributing
165167

166168
Contributions in all forms are welcome.
@@ -192,4 +194,4 @@ the [website](https://felixlemke.com).
192194

193195
## Dependencies
194196

195-
- [opn](https://www.npmjs.com/package/opn)
197+
- [opn](https://www.npmjs.com/package/opn)

src/plot.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { IPlot, IPlotsContainer } from './models/index';
22
import { Layout, Plot } from './models/index';
33
import { Server } from './server';
44

5-
6-
const server = new Server(8080);
5+
const port = Number(process.env.PORT) || 8080;
6+
const server = new Server(port);
77

88
export let plots: IPlot[] = [];
99
export const plotContainer: IPlotsContainer = {};
@@ -62,4 +62,4 @@ function validate(data: Plot[], layout?: Layout) {
6262
throw new TypeError('Layout must be an object');
6363
}
6464
}
65-
}
65+
}

test/server.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import opn from 'opn';
22
import request from 'request';
33
import { Server } from '../src/server';
44

5-
const port = 8080;
5+
const port = Number(process.env.PORT) || 8080;
66
const validData = {
77
opened: false,
88
pending: false,

0 commit comments

Comments
 (0)