mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Splitted Webserver from operative module
This commit is contained in:
15
index.js
15
index.js
@@ -4,19 +4,15 @@ const path = require("path");
|
|||||||
const crypto = require("crypto");
|
const crypto = require("crypto");
|
||||||
const { spawn } = require("child_process");
|
const { spawn } = require("child_process");
|
||||||
const archiver = require("archiver");
|
const archiver = require("archiver");
|
||||||
const express = require("express");
|
|
||||||
const async = require("async");
|
const async = require("async");
|
||||||
|
|
||||||
const _configuration = Object.freeze(require("./config.json"));
|
const _configuration = Object.freeze(require("./config.json"));
|
||||||
|
|
||||||
const instance = express();
|
|
||||||
const supportedTypesOfPass = /(boardingPass|eventTicket|coupon|generic|storeCard)/i;
|
const supportedTypesOfPass = /(boardingPass|eventTicket|coupon|generic|storeCard)/i;
|
||||||
const passModelsDir = _configuration.models.dir;
|
const passModelsDir = _configuration.models.dir;
|
||||||
const outputDir = _configuration.output.dir;
|
const outputDir = _configuration.output.dir;
|
||||||
const Certificates = _configuration.certificates;
|
const Certificates = _configuration.certificates;
|
||||||
|
|
||||||
instance.use(express.json());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Apply a filter to arg0 to remove hidden files names (starting with dot)
|
Apply a filter to arg0 to remove hidden files names (starting with dot)
|
||||||
@function removeDotFiles
|
@function removeDotFiles
|
||||||
@@ -372,13 +368,4 @@ function RequestHandler(request, response) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.listen(80, "0.0.0.0", function(request, response) {
|
module.exports = { RequestHandler };
|
||||||
console.log("Listening on 80");
|
|
||||||
});
|
|
||||||
|
|
||||||
instance.get("/", function (request, response) {
|
|
||||||
response.send("Hello there!");
|
|
||||||
});
|
|
||||||
|
|
||||||
instance.get("/gen/:type/", RequestHandler);
|
|
||||||
instance.post("/gen/:type/", RequestHandler);
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "A passkit generator webserver",
|
"description": "A passkit generator webserver",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js"
|
"start": "node server.js"
|
||||||
},
|
},
|
||||||
"author": "Alexander Patrick Cerutti",
|
"author": "Alexander Patrick Cerutti",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|||||||
17
server.js
Normal file
17
server.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const { RequestHandler } = require("./index")
|
||||||
|
|
||||||
|
const instance = express();
|
||||||
|
|
||||||
|
instance.use(express.json());
|
||||||
|
|
||||||
|
instance.listen(80, "0.0.0.0", function(request, response) {
|
||||||
|
console.log("Listening on 80");
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.get("/", function (request, response) {
|
||||||
|
response.send("Hello there!");
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.get("/gen/:type/", RequestHandler);
|
||||||
|
instance.post("/gen/:type/", RequestHandler);
|
||||||
Reference in New Issue
Block a user