Skip to content

Commit b9e27dd

Browse files
committed
bump to 0.0.76
1 parent ccb8331 commit b9e27dd

2 files changed

Lines changed: 46 additions & 47 deletions

File tree

OpenFlowNodeRED/src/WebServer.ts

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as path from "path";
22
import * as winston from "winston";
33
import * as http from "http";
44
import * as https from "https";
5-
import * as express from "express";
5+
import * as express from "express";
66
import * as compression from "compression";
77
import * as bodyParser from "body-parser";
88
import * as cookieParser from "cookie-parser";
@@ -20,28 +20,28 @@ import { noderedcontribmiddlewareauth } from "./node-red-contrib-middleware-auth
2020

2121
export class WebServer {
2222
private static _logger: winston.Logger;
23-
private static app:express.Express = null;
23+
private static app: express.Express = null;
2424

25-
private static settings:nodered_settings = null;
26-
static async configure(logger: winston.Logger, socket:WebSocketClient): Promise<http.Server> {
25+
private static settings: nodered_settings = null;
26+
static async configure(logger: winston.Logger, socket: WebSocketClient): Promise<http.Server> {
2727
this._logger = logger;
2828

29-
var options:any = null;
30-
var RED:nodered.Red = nodered;
29+
var options: any = null;
30+
var RED: nodered.Red = nodered;
3131

32-
if(this.app!== null) { return; }
32+
if (this.app !== null) { return; }
3333

3434
try {
35-
if(this.app=== null) {
35+
if (this.app === null) {
3636
this.app = express();
3737
this.app.use(compression());
38-
this.app.use(bodyParser.urlencoded({limit: '10mb', extended: true}))
39-
this.app.use(bodyParser.json({limit: '10mb'}))
38+
this.app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }))
39+
this.app.use(bodyParser.json({ limit: '10mb' }))
4040
this.app.use(cookieParser());
4141
this.app.use("/", express.static(path.join(__dirname, "/public")));
42-
var server:http.Server = null;
42+
var server: http.Server = null;
4343
if (Config.tls_crt != '' && Config.tls_key != '') {
44-
var options:any = {
44+
var options: any = {
4545
cert: Config.tls_crt,
4646
key: Config.tls_key
4747
};
@@ -51,18 +51,17 @@ export class WebServer {
5151
key: Buffer.from(Config.tls_key, 'base64').toString('ascii')
5252
};
5353
}
54-
var ca:string = Config.tls_ca;
55-
if (ca!== "") {
56-
if(ca.indexOf("---") === -1) {
54+
var ca: string = Config.tls_ca;
55+
if (ca !== "") {
56+
if (ca.indexOf("---") === -1) {
5757
ca = Buffer.from(ca, 'base64').toString('ascii');
5858
}
59-
if(ca.indexOf("---") > -1) {
60-
console.log(ca);
59+
if (ca.indexOf("---") > -1) {
6160
options.ca = ca;
6261
}
6362
// options.cert += "\n" + ca;
6463
}
65-
if(Config.tls_passphrase!=="") {
64+
if (Config.tls_passphrase !== "") {
6665
options.passphrase = Config.tls_passphrase;
6766
}
6867
server = https.createServer(options, this.app);
@@ -74,70 +73,70 @@ export class WebServer {
7473
console.error(error);
7574
process.exit(404);
7675
});
77-
76+
7877
this.settings = new nodered_settings();
7978
this.settings.userDir = path.join(__dirname, "./nodered");
8079
this.settings.nodesDir = path.join(__dirname, "./nodered");
81-
80+
8281

8382
// this.settings.adminAuth = new googleauth.noderedcontribauthgoogle(Config.baseurl(), Config.consumer_key, Config.consumer_secret,
8483
// (profile:string | any, done:any)=> {
8584
// profile.permissions = "*";
8685
// done(profile);
8786
// });
88-
this.settings.adminAuth = await samlauth.noderedcontribauthsaml.configure(Config.baseurl(), Config.saml_federation_metadata, Config.saml_issuer,
89-
(profile:string | any, done:any)=> {
90-
// profile.permissions = "*";
91-
done(profile);
92-
}, "");
87+
this.settings.adminAuth = await samlauth.noderedcontribauthsaml.configure(Config.baseurl(), Config.saml_federation_metadata, Config.saml_issuer,
88+
(profile: string | any, done: any) => {
89+
// profile.permissions = "*";
90+
done(profile);
91+
}, "");
9392
// this.settings.adminAuth = await noderedcontribauthsaml.configure(this._logger, Config.baseurl());clear
9493

9594
// settings.adminAuth = new noderedcontribauthopenid(this._logger, Config.baseurl());
9695

97-
this.settings.httpNodeMiddleware = (req:express.Request,res:express.Response,next:express.NextFunction) => {
98-
noderedcontribmiddlewareauth.process(socket, req, res, next);
96+
this.settings.httpNodeMiddleware = (req: express.Request, res: express.Response, next: express.NextFunction) => {
97+
noderedcontribmiddlewareauth.process(socket, req, res, next);
9998
};
10099

101100
this.settings.storageModule = new noderedcontribopenflowstorage(logger, socket);
102-
101+
103102
// initialise the runtime with a server and settings
104-
await (RED as any).init(server,this.settings);
105-
103+
await (RED as any).init(server, this.settings);
104+
106105
// serve the editor UI from /red
107-
this.app.use(this.settings.httpAdminRoot,RED.httpAdmin);
108-
106+
this.app.use(this.settings.httpAdminRoot, RED.httpAdmin);
107+
109108
// serve the http nodes UI from /api
110-
this.app.use(this.settings.httpNodeRoot,RED.httpNode);
109+
this.app.use(this.settings.httpNodeRoot, RED.httpNode);
111110

112111
server.listen(Config.port);
113112
} else {
114113
await RED.stop();
115114
// initialise the runtime with a server and settings
116-
await (RED as any).init(server,this.settings);
117-
115+
await (RED as any).init(server, this.settings);
116+
118117
// serve the editor UI from /red
119-
this.app.use(this.settings.httpAdminRoot,RED.httpAdmin);
120-
118+
this.app.use(this.settings.httpAdminRoot, RED.httpAdmin);
119+
121120
// serve the http nodes UI from /api
122-
this.app.use(this.settings.httpNodeRoot,RED.httpNode);
121+
this.app.use(this.settings.httpNodeRoot, RED.httpNode);
123122
}
124123

125-
var hasErrors:boolean = true; var errorCounter:number = 0;
126-
var err:any;
127-
while(hasErrors) {
124+
var hasErrors: boolean = true; var errorCounter: number = 0;
125+
var err: any;
126+
while (hasErrors) {
128127
try {
129128
RED.start();
130129
hasErrors = false;
131130
} catch (error) {
132-
err=error;
131+
err = error;
133132
errorCounter++;
134133
hasErrors = true;
135134
console.error(error);
136135
}
137-
if(errorCounter==10) {
138-
throw err;
139-
} else if(hasErrors) {
140-
var wait = ms => new Promise((r, j)=>setTimeout(r, ms));
136+
if (errorCounter == 10) {
137+
throw err;
138+
} else if (hasErrors) {
139+
var wait = ms => new Promise((r, j) => setTimeout(r, ms));
141140
await wait(2000);
142141
}
143142
}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.75
1+
0.0.76

0 commit comments

Comments
 (0)