summaryrefslogtreecommitdiff
path: root/src/sources/HttpSource.ts
diff options
context:
space:
mode:
authorTim Schiewe <git@tforge.de>2018-04-30 19:18:46 +0200
committerTim Schiewe <git@tforge.de>2018-04-30 19:18:46 +0200
commitac85779f3b67ffc2953c17d0824be62b1f0acc86 (patch)
tree5442df8297c3620ed72af7e3ece2a77ad58cce35 /src/sources/HttpSource.ts
parent93b466df50d94d4c15715f5eb4d88a0be7d61c11 (diff)
downloadsplus-ac85779f3b67ffc2953c17d0824be62b1f0acc86.tar.gz
splus-ac85779f3b67ffc2953c17d0824be62b1f0acc86.zip
Implement interface/config based infrastructure
Fixes #2
Diffstat (limited to 'src/sources/HttpSource.ts')
-rw-r--r--src/sources/HttpSource.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/sources/HttpSource.ts b/src/sources/HttpSource.ts
new file mode 100644
index 0000000..45ddd7a
--- /dev/null
+++ b/src/sources/HttpSource.ts
@@ -0,0 +1,22 @@
+import {get} from 'http';
+
+import {ISource} from './ISource';
+
+export class HttpSource implements ISource {
+ private _uri: string;
+
+ constructor(path: string) {
+ this._uri = path;
+ }
+
+ getData(): Promise<string> {
+ return new Promise<string>((resolve, reject) => {
+ get(this._uri, (res) => {
+ let data = '';
+ res.on('error', reject);
+ res.on('data', chunk => data += chunk);
+ res.on('end', () => resolve(data));
+ });
+ });
+ }
+}