TypeScript!
This commit is contained in:
1 parent
ee8c43747e
commit
5d3c81cb23
105 files changed
+12054
-1901
No files matched your search
+9
-11
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env -S node -r esm
|
||||
"use strict";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
#!/usr/bin/env -S node -r esm -r ts-node/register/transpile-only
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
|
||||
process.chdir(path.resolve(path.dirname(fs.realpathSync(__filename)), ".."));
|
||||
|
||||
@@ -13,7 +12,6 @@ import * as cwmp from "../lib/cwmp";
|
||||
import * as db from "../lib/db";
|
||||
import * as extensions from "../lib/extensions";
|
||||
import * as cache from "../lib/cache";
|
||||
|
||||
import { version as VERSION } from "../package.json";
|
||||
|
||||
logger.init("cwmp", VERSION);
|
||||
@@ -21,14 +19,14 @@ logger.init("cwmp", VERSION);
|
||||
const SERVICE_ADDRESS = config.get("CWMP_INTERFACE");
|
||||
const SERVICE_PORT = config.get("CWMP_PORT");
|
||||
|
||||
function exitWorkerGracefully() {
|
||||
function exitWorkerGracefully(): void {
|
||||
db.disconnect();
|
||||
cache.disconnect();
|
||||
extensions.killAll();
|
||||
cluster.worker.disconnect();
|
||||
}
|
||||
|
||||
function exitWorkerUngracefully() {
|
||||
function exitWorkerUngracefully(): void {
|
||||
extensions.killAll(() => {
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -66,14 +64,14 @@ if (!cluster.worker) {
|
||||
let ssl;
|
||||
if (config.get("CWMP_SSL")) {
|
||||
ssl = {
|
||||
key: path.resolve(config.get("CONFIG_DIR"), "cwmp.key"),
|
||||
cert: path.resolve(config.get("CONFIG_DIR"), "cwmp.crt"),
|
||||
ca: path.resolve(config.get("CONFIG_DIR"), "cwmp.ca-bundle")
|
||||
key: path.resolve("" + config.get("CONFIG_DIR"), "cwmp.key"),
|
||||
cert: path.resolve("" + config.get("CONFIG_DIR"), "cwmp.crt"),
|
||||
ca: path.resolve("" + config.get("CONFIG_DIR"), "cwmp.ca-bundle")
|
||||
};
|
||||
}
|
||||
|
||||
process.on("uncaughtException", err => {
|
||||
if (err.code === "ERR_IPC_DISCONNECTED") return;
|
||||
if ((err as NodeJS.ErrnoException).code === "ERR_IPC_DISCONNECTED") return;
|
||||
logger.error({
|
||||
message: "Uncaught exception",
|
||||
exception: err,
|
||||
|
||||
+6
-4
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env -S node -r esm
|
||||
#!/usr/bin/env -S node -r esm -r ts-node/register/transpile-only
|
||||
|
||||
/**
|
||||
* Copyright 2013-2018 Zaid Abdulla
|
||||
*
|
||||
@@ -17,18 +18,19 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
import { Fault } from "../lib/types";
|
||||
|
||||
const jobs = new Set();
|
||||
const fileName = process.argv[2];
|
||||
let script;
|
||||
|
||||
function errorToFault(err) {
|
||||
function errorToFault(err: Error): Fault {
|
||||
if (!err) return null;
|
||||
|
||||
if (!err.name) return { code: "ext", message: `${err}` };
|
||||
|
||||
const fault = {
|
||||
const fault: Fault = {
|
||||
code: `ext.${err.name}`,
|
||||
message: err.message,
|
||||
detail: {
|
||||
|
||||
+9
-10
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env -S node -r esm
|
||||
"use strict";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
#!/usr/bin/env -S node -r esm -r ts-node/register/transpile-only
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
|
||||
process.chdir(path.resolve(path.dirname(fs.realpathSync(__filename)), ".."));
|
||||
|
||||
@@ -19,13 +18,13 @@ logger.init("fs", VERSION);
|
||||
const SERVICE_ADDRESS = config.get("FS_INTERFACE");
|
||||
const SERVICE_PORT = config.get("FS_PORT");
|
||||
|
||||
function exitWorkerGracefully() {
|
||||
function exitWorkerGracefully(): void {
|
||||
db.disconnect();
|
||||
cache.disconnect();
|
||||
cluster.worker.disconnect();
|
||||
}
|
||||
|
||||
function exitWorkerUngracefully() {
|
||||
function exitWorkerUngracefully(): void {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -61,14 +60,14 @@ if (!cluster.worker) {
|
||||
let ssl;
|
||||
if (config.get("FS_SSL")) {
|
||||
ssl = {
|
||||
key: path.resolve(config.get("CONFIG_DIR"), "fs.key"),
|
||||
cert: path.resolve(config.get("CONFIG_DIR"), "fs.crt"),
|
||||
ca: path.resolve(config.get("CONFIG_DIR"), "fs.ca-bundle")
|
||||
key: path.resolve("" + config.get("CONFIG_DIR"), "fs.key"),
|
||||
cert: path.resolve("" + config.get("CONFIG_DIR"), "fs.crt"),
|
||||
ca: path.resolve("" + config.get("CONFIG_DIR"), "fs.ca-bundle")
|
||||
};
|
||||
}
|
||||
|
||||
process.on("uncaughtException", err => {
|
||||
if (err.code === "ERR_IPC_DISCONNECTED") return;
|
||||
if ((err as NodeJS.ErrnoException).code === "ERR_IPC_DISCONNECTED") return;
|
||||
logger.error({
|
||||
message: "Uncaught exception",
|
||||
exception: err,
|
||||
|
||||
+9
-10
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env -S node -r esm
|
||||
"use strict";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
#!/usr/bin/env -S node -r esm -r ts-node/register/transpile-only
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
|
||||
process.chdir(path.resolve(path.dirname(fs.realpathSync(__filename)), ".."));
|
||||
|
||||
@@ -20,14 +19,14 @@ logger.init("nbi", VERSION);
|
||||
const SERVICE_ADDRESS = config.get("NBI_INTERFACE");
|
||||
const SERVICE_PORT = config.get("NBI_PORT");
|
||||
|
||||
function exitWorkerGracefully() {
|
||||
function exitWorkerGracefully(): void {
|
||||
db.disconnect();
|
||||
cache.disconnect();
|
||||
extensions.killAll();
|
||||
cluster.worker.disconnect();
|
||||
}
|
||||
|
||||
function exitWorkerUngracefully() {
|
||||
function exitWorkerUngracefully(): void {
|
||||
extensions.killAll(() => {
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -65,14 +64,14 @@ if (!cluster.worker) {
|
||||
let ssl;
|
||||
if (config.get("NBI_SSL")) {
|
||||
ssl = {
|
||||
key: path.resolve(config.get("CONFIG_DIR"), "nbi.key"),
|
||||
cert: path.resolve(config.get("CONFIG_DIR"), "nbi.crt"),
|
||||
ca: path.resolve(config.get("CONFIG_DIR"), "nbi.ca-bundle")
|
||||
key: path.resolve("" + config.get("CONFIG_DIR"), "nbi.key"),
|
||||
cert: path.resolve("" + config.get("CONFIG_DIR"), "nbi.crt"),
|
||||
ca: path.resolve("" + config.get("CONFIG_DIR"), "nbi.ca-bundle")
|
||||
};
|
||||
}
|
||||
|
||||
process.on("uncaughtException", err => {
|
||||
if (err.code === "ERR_IPC_DISCONNECTED") return;
|
||||
if ((err as NodeJS.ErrnoException).code === "ERR_IPC_DISCONNECTED") return;
|
||||
logger.error({
|
||||
message: "Uncaught exception",
|
||||
exception: err,
|
||||
|
||||
+8
-9
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env -S node -r esm
|
||||
"use strict";
|
||||
#!/usr/bin/env -S node -r esm -r ts-node/register/transpile-only
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
|
||||
@@ -20,14 +19,14 @@ logger.init("ui", VERSION);
|
||||
const SERVICE_ADDRESS = config.get("UI_INTERFACE");
|
||||
const SERVICE_PORT = config.get("UI_PORT");
|
||||
|
||||
function exitWorkerGracefully() {
|
||||
function exitWorkerGracefully(): void {
|
||||
db.disconnect();
|
||||
db2.disconnect();
|
||||
cache.disconnect();
|
||||
cluster.worker.disconnect();
|
||||
}
|
||||
|
||||
function exitWorkerUngracefully() {
|
||||
function exitWorkerUngracefully(): void {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -63,16 +62,16 @@ if (!cluster.worker) {
|
||||
let ssl;
|
||||
if (config.get("UI_SSL")) {
|
||||
ssl = {
|
||||
key: path.resolve(config.get("CONFIG_DIR"), "ui.key"),
|
||||
cert: path.resolve(config.get("CONFIG_DIR"), "ui.crt"),
|
||||
ca: path.resolve(config.get("CONFIG_DIR"), "ui.ca-bundle")
|
||||
key: path.resolve("" + config.get("CONFIG_DIR"), "ui.key"),
|
||||
cert: path.resolve("" + config.get("CONFIG_DIR"), "ui.crt"),
|
||||
ca: path.resolve("" + config.get("CONFIG_DIR"), "ui.ca-bundle")
|
||||
};
|
||||
}
|
||||
|
||||
let stopping = false;
|
||||
|
||||
process.on("uncaughtException", err => {
|
||||
if (err.code === "ERR_IPC_DISCONNECTED") return;
|
||||
if ((err as NodeJS.ErrnoException).code === "ERR_IPC_DISCONNECTED") return;
|
||||
logger.error({
|
||||
message: "Uncaught exception",
|
||||
exception: err,
|
||||
@@ -101,7 +100,7 @@ if (!cluster.worker) {
|
||||
.catch(exitWorkerUngracefully);
|
||||
});
|
||||
|
||||
const _listener = (req, res) => {
|
||||
const _listener = (req, res): void => {
|
||||
if (stopping) res.setHeader("Connection", "close");
|
||||
listener(req, res);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user