aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2019-12-29 00:24:49 -0500
committerKevin J Hoerr <kjhoerr@protonmail.com>2019-12-29 00:24:49 -0500
commit5f99b8e36d22a54a6a5ef17b43c1b3c33e560cef (patch)
tree24743f5edaf63062b1318153fa83c6db01afd52e
parent21cc6c9748ea4567dee5f62f7f1dcc0b8cd1b069 (diff)
downloadao-coverage-5f99b8e36d22a54a6a5ef17b43c1b3c33e560cef.tar.gz
ao-coverage-5f99b8e36d22a54a6a5ef17b43c1b3c33e560cef.tar.bz2
ao-coverage-5f99b8e36d22a54a6a5ef17b43c1b3c33e560cef.zip
Add index.html template with route for integration
-rw-r--r--public/index.html.template17
-rw-r--r--src/index.ts11
-rw-r--r--src/routes.ts5
3 files changed, 33 insertions, 0 deletions
diff --git a/public/index.html.template b/public/index.html.template
new file mode 100644
index 0000000..0dfbee7
--- /dev/null
+++ b/public/index.html.template
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en-US">
+
+<head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta http-equiv="x-ua-compatible" content="ie=edge" />
+ <title>AO Coverage: Simple code coverage tracking</title>
+</head>
+
+<body>
+ <div id="content">
+ <span class="code">bash &lt;(curl -s {{TARGET_URL}}/bash)</span>
+ </div>
+</body>
+
+</html> \ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
index 7d018fe..6749ae1 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -38,16 +38,27 @@ const bashTemplate = {
outputFile: path.join(HOST_DIR, "bash"),
context: { TARGET_URL }
} as Template;
+const indexTemplate = {
+ inputFile: path.join(__dirname, "..", "public", "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);
diff --git a/src/routes.ts b/src/routes.ts
index c3b2832..9ce3bbc 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -20,6 +20,11 @@ const logger = winston.createLogger(loggerConfig("HTTP"));
export default (metadata: Metadata): Router => {
const router = Router();
+ // serve landing page
+ router.get("/", (_, res) => {
+ res.sendFile(path.join(HOST_DIR, "index.html"))
+ });
+
// serve script for posting coverage report
router.use(
"/bash",