Convert backend code to ES modules
Bundling code now with Rollup for its flat bundling and tree shaking support. Front end code still goes through Webpack for browser support.
This commit is contained in:
1 parent
824639976f
commit
1e41c72d60
62 files changed
+718
-898
No files matched your search
+13
-16
@@ -18,18 +18,17 @@
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const url = require("url");
|
||||
const mongodb = require("mongodb");
|
||||
const querystring = require("querystring");
|
||||
const vm = require("vm");
|
||||
const childProcess = require("child_process");
|
||||
const config = require("./config");
|
||||
const db = require("./db");
|
||||
const query = require("./query");
|
||||
const apiFunctions = require("./api-functions");
|
||||
const cache = require("./cache");
|
||||
|
||||
const VERSION = require("../package.json").version;
|
||||
import url from "url";
|
||||
import mongodb from "mongodb";
|
||||
import querystring from "querystring";
|
||||
import vm from "vm";
|
||||
import { exec } from "child_process";
|
||||
import * as config from "./config";
|
||||
import * as db from "./db";
|
||||
import * as query from "./query";
|
||||
import * as apiFunctions from "./api-functions";
|
||||
import * as cache from "./cache";
|
||||
import { version as VERSION } from "../package.json";
|
||||
|
||||
const DEVICE_TASKS_REGEX = /^\/devices\/([a-zA-Z0-9\-_%]+)\/tasks\/?$/;
|
||||
const TASKS_REGEX = /^\/tasks\/([a-zA-Z0-9\-_%]+)(\/[a-zA-Z_]*)?$/;
|
||||
@@ -52,7 +51,7 @@ function throwError(err, httpResponse) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
function listener(request, response) {
|
||||
export function listener(request, response) {
|
||||
const chunks = [];
|
||||
let bytes = 0;
|
||||
response.setHeader("GenieACS-Version", VERSION);
|
||||
@@ -520,7 +519,7 @@ function listener(request, response) {
|
||||
}
|
||||
} else if (PING_REGEX.test(urlParts.pathname)) {
|
||||
const host = querystring.unescape(PING_REGEX.exec(urlParts.pathname)[1]);
|
||||
childProcess.exec(`ping -w 1 -i 0.2 -c 3 ${host}`, (err, stdout) => {
|
||||
exec(`ping -w 1 -i 0.2 -c 3 ${host}`, (err, stdout) => {
|
||||
if (err) {
|
||||
response.writeHead(404, { "Cache-Control": "no-cache" });
|
||||
response.end(`${err.name}: ${err.message}`);
|
||||
@@ -661,5 +660,3 @@ function listener(request, response) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exports.listener = listener;
|
||||
Reference in new issue
Block a user