diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | package.json | 4 | ||||
| -rw-r--r-- | src/serverConfig.ts | 65 |
3 files changed, 67 insertions, 5 deletions
@@ -14,3 +14,6 @@ POSTGRES_logfile # Vim swap files *.sw* + +# Typedoc-generated documentation +docs/ diff --git a/package.json b/package.json index 2f9c6fd..381ff95 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "license": "UNLICENSED", "scripts": { "test": "mocha --reporter spec -r ts-node/register 'test/**/*.test.ts'", + "docs": "typedoc --out 'docs' --readme 'README.md' --name 'St Andrews Junior Honours 2017/18 - Team BE4' --module commonjs --target ES5 --exclude '*.test.ts' --includeDeclarations --excludeExternals 'src'", "start": "ts-node src/index.ts" }, "repository": { @@ -27,7 +28,8 @@ "chai": "^3.5.0", "chai-http": "^3.0.0", "mocha": "^3.1.2", - "nodemon": "^1.14.10" + "nodemon": "^1.14.10", + "typedoc": "^0.10.0" }, "dependencies": { "@types/body-parser": "0.0.33", diff --git a/src/serverConfig.ts b/src/serverConfig.ts index b10641a..1ef7c83 100644 --- a/src/serverConfig.ts +++ b/src/serverConfig.ts @@ -1,31 +1,81 @@ var serverConfig : Property[] = []; -/* This is a class used to define the optional attribute of Property, - if the property is user configurable*/ +/** + * A way to display user-configurable properties. + */ class PropertyDisplay { + /** + * Constructs a [[PropertyDisplay]] using its properties. + * + * @param cat The property's category. + * @param grp The property's group. + * @param dn The property's displayable name. + * @param desc A description of the property. + */ constructor(cat : string, grp : string, dn : string, desc : string) { this.category = cat; this.group = grp; this.display_name = dn; this.description = desc; }; + + /** + * The category the property belongs to. + */ category : string; + + /** + * The group the property belongs to. + */ group : string; + + /** + * The name for the property to display to a user. + */ display_name : string; + + /** + * The description of the property. + */ description : string; }; /* This is a class used to contain all of the protocol attributes of a Property of the current backend server.*/ +/** + * A server property that infuences the running of the server. + * Loaded from configs at launch, and possibly editable during run-time. + */ class Property { + /** + * The property's unique ID. + */ id : string; + + /** + * How to display the property to the user. + */ display? : PropertyDisplay; + + /** + * Is the property read-only, or can it be edited at run-time? + */ read_only : boolean; - type : string; + + /** + * The variable type of the property. + * + * These strings represent Javascript types directly, + * except `"integer"`, which is a `number` in logic. + */ + type : "string" | "number" | "integer" | "boolean"; + + /** + * The value of the property. + */ value : string | number | boolean; } -//Logging var property_display = new PropertyDisplay("Logging", "BE4", "Is logging enabled?", "This property defines if logging is currently enabled on this backend server."); serverConfig.push({id : "Server_Log", display : property_display, read_only : false, type : "boolean", value : false}); @@ -35,6 +85,13 @@ serverConfig.push({id : "Global_Cache_Limit", read_only : true, type : "integer" property_display = new PropertyDisplay("Caching", "BE4", "Caching Type", "This property defines the current caching style for this project."); serverConfig.push({id : "project_example", display : property_display, read_only : false, type : "integer", value : 1}); +/** + * Checks if a property exists in the server's property list. + * + * @param propKey The property unique ID to search for. + * @returns The index of the property in the server's property list, + * or `-1` if the property is not present. + */ function propertyExists (propKey : string): number { var found = -1; for (var prop in serverConfig) { |
