diff --git a/.gitignore b/.gitignore
index dcc8f16..cc6afae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,6 @@ src/**/index.js
node_modules
# typescript output
-bin/delta-processor.js
+bin/*.js
tsconfig.tsbuildinfo
diff --git a/bin/server.ts b/bin/server.ts
index ec93fb7..0e8445a 100644
--- a/bin/server.ts
+++ b/bin/server.ts
@@ -1,7 +1,7 @@
/**
* Start the Liza Server
*
- * Copyright (C) 2017 R-T Specialty, LLC.
+ * Copyright (C) 2010-2019 R-T Specialty, LLC.
*
* This file is part of the Liza Data Collection Framework.
*
@@ -19,19 +19,12 @@
* along with this program. If not, see .
*/
-'use strict';
+import fs = require( 'fs' );
+import path = require( 'path' );
-const fs = require( 'fs' );
-const path = require( 'path' );
-
-const {
- conf: {
- ConfLoader,
- ConfStore,
- },
- server,
- version,
-} = require( '../' );
+import { ConfLoader } from "../src/conf/ConfLoader";
+import { ConfStore } from "../src/conf/ConfStore";
+import * as version from "../src/version";
// kluge for now
const conf_path = (
@@ -42,7 +35,7 @@ const conf_path = (
const conf_dir = path.dirname( conf_path );
-ConfLoader( fs, ConfStore )
+new ConfLoader( fs, ConfStore )
.fromFile( conf_path )
.then( conf => Promise.all( [
conf.get( 'name' ),
@@ -70,12 +63,12 @@ ConfLoader( fs, ConfStore )
* Produce an absolute path if `path` is absolute, otherwise a path relative
* to the configuration directory
*
- * @param {string} conf_path configuration path (for relative `path`)
- * @param {string} path path to resolve
+ * @param conf_path - configuration path (for relative `path`)
+ * @param path - path to resolve
*
* @return resolved path
*/
-function _resolvePath( conf_path, path )
+function _resolvePath( conf_path: string, path: string ): string
{
return ( path[ 0 ] === '/' )
? path
@@ -83,7 +76,12 @@ function _resolvePath( conf_path, path )
}
-function writePidFile( pid_path )
+/**
+ * Write process id (PID) file
+ *
+ * @param pid_path - path to pid file
+ */
+function writePidFile( pid_path: string ): void
{
fs.writeFile( pid_path, process.pid );
@@ -91,7 +89,16 @@ function writePidFile( pid_path )
}
-function greet( name, pid_path )
+/**
+ * Output greeting
+ *
+ * The greeting contains the program name, version, configuration path,
+ * and PID file path.
+ *
+ * @param name - program name
+ * @param pid_path - path to PID file
+ */
+function greet( name: string, pid_path: string ): void
{
console.log( `${name} (liza-${version})`);
console.log( `Server configuration: ${conf_path}` );
diff --git a/src/conf/ConfLoader.js b/src/conf/ConfLoader.ts
similarity index 74%
rename from src/conf/ConfLoader.js
rename to src/conf/ConfLoader.ts
index 17f26ed..7d556e5 100644
--- a/src/conf/ConfLoader.js
+++ b/src/conf/ConfLoader.ts
@@ -19,9 +19,8 @@
* along with this program. If not, see .
*/
-'use strict';
-
-const { Class } = require( 'easejs' );
+import { readFile } from "fs";
+import { Store } from "../store/Store";
/**
@@ -35,21 +34,8 @@ const { Class } = require( 'easejs' );
* TODO: Merging multiple configuration files would be convenient for
* modular configuration.
*/
-module.exports = Class( 'ConfLoader',
+export class ConfLoader
{
- /**
- * Filesystem module
- * @type {fs}
- */
- 'private _fs': null,
-
- /**
- * Store object constructor
- * @type {function():Store}
- */
- 'private _storeCtor': null,
-
-
/**
* Initialize with provided filesystem module and Store constructor
*
@@ -57,14 +43,13 @@ module.exports = Class( 'ConfLoader',
* Node.js'. The Store constructor `store_ctor` is used to instantiate
* new stores to be populated with configuration data.
*
- * @param {fs} fs filesystem module
- * @param {function():Store} store_ctor Store object constructor
+ * @param fs - filesystem module
+ * @param store_ctor - Store object constructor
*/
- constructor( fs, store_ctor )
- {
- this._fs = fs;
- this._storeCtor = store_ctor;
- },
+ constructor(
+ private _fs: { readFile: typeof readFile },
+ private _storeCtor: () => Store,
+ ) {}
/**
@@ -72,11 +57,11 @@ module.exports = Class( 'ConfLoader',
*
* A Store will be produced, populated with the configuration data.
*
- * @param {string} filename path to configuration JSON
+ * @param filename - path to configuration JSON
*
- * @return {Promise.} a promise of a populated Store
+ * @return a promise of a populated Store
*/
- 'public fromFile'( filename )
+ fromFile( filename: string ): Promise
{
return new Promise( ( resolve, reject ) =>
{
@@ -104,7 +89,7 @@ module.exports = Class( 'ConfLoader',
}
} );
} );
- },
+ }
/**
@@ -112,12 +97,12 @@ module.exports = Class( 'ConfLoader',
*
* Parses configuration string as JSON.
*
- * @param {string} data raw configuration data
+ * @param data raw configuration data
*
- * @return {Promise.