aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2020-01-11 21:41:41 -0500
committerKevin J Hoerr <kjhoerr@protonmail.com>2020-01-11 21:41:41 -0500
commitc7ebf8009e27256db7eb36fa259c250bd80dbf09 (patch)
tree93e111f5e4c1084de9f9105a7b5a06b5dc2464eb /src/index.ts
parentedfdc5cfcfa9b7df9f5c7b5ff53f432b0579b433 (diff)
downloadao-coverage-c7ebf8009e27256db7eb36fa259c250bd80dbf09.tar.gz
ao-coverage-c7ebf8009e27256db7eb36fa259c250bd80dbf09.tar.bz2
ao-coverage-c7ebf8009e27256db7eb36fa259c250bd80dbf09.zip
#8 Add router unit tests using supertest
Also moved the template processing from index to router.
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts35
1 files changed, 0 insertions, 35 deletions
diff --git a/src/index.ts b/src/index.ts
index 71da73c..76620e8 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -9,7 +9,6 @@ import expressWinston from "express-winston";
dotenv.config();
-import processTemplate, { Template } from "./templates";
import routes from "./routes";
import Metadata from "./metadata";
import loggerConfig from "./util/logger";
@@ -18,7 +17,6 @@ import { configOrError, handleShutdown } from "./util/config";
// Start-up configuration
const BIND_ADDRESS = process.env.BIND_ADDRESS ?? "localhost";
const PORT = Number(process.env.PORT ?? 3000);
-const TARGET_URL = process.env.TARGET_URL ?? "http://localhost:3000";
const logger = winston.createLogger(loggerConfig("ROOT"));
@@ -32,39 +30,6 @@ if (!path.isAbsolute(HOST_DIR)) {
process.exit(1);
}
-// prepare template files
-const bashTemplate = {
- inputFile: path.join(__dirname, "..", "public", "templates", "bash.template"),
- outputFile: path.join(HOST_DIR, "bash"),
- context: { TARGET_URL }
-} as Template;
-const indexTemplate = {
- inputFile: path.join(__dirname, "..", "public", "templates", "index.html.template"),
- outputFile: path.join(HOST_DIR, "index.html"),
- context: { TARGET_URL }
-} as Template;
-
-processTemplate(bashTemplate)
- .then(template => {
- logger.debug("Generated '%s' from template file", template.outputFile);
- })
- .then(() => processTemplate(indexTemplate))
- .then(template => {
- logger.debug("Generated '%s' from template file", template.outputFile);
- })
- .catch(err => {
- logger.error("Unable to process template file: %s", err);
-
- // if the output file exists, then we are fine with continuing without
- return fs.promises.access(bashTemplate.outputFile, fs.constants.R_OK);
- })
- .then(() => fs.promises.access(indexTemplate.outputFile, fs.constants.R_OK))
- .catch(err => {
- logger.error("Cannot proceed: %s", err);
-
- process.exit(1);
- });
-
new MongoClient(MONGO_URI, { useUnifiedTopology: true }).connect(
(err, mongo) => {
if (err !== null) {