Added authorization server and backup of JSReport config. IO-585
This commit is contained in:
54
jsreport/auth-server/server.js
Normal file
54
jsreport/auth-server/server.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const express = require("express");
|
||||
const cors = require("cors");
|
||||
const bodyParser = require("body-parser");
|
||||
const path = require("path");
|
||||
const compression = require("compression");
|
||||
global.fetch = require("node-fetch");
|
||||
var fb = require("./firebase/firebase-handler");
|
||||
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const https = require("https");
|
||||
const fs = require("fs");
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 5000;
|
||||
//const port = 5000;
|
||||
|
||||
//app.use(fb.validateFirebaseIdToken);
|
||||
app.use(compression());
|
||||
app.use(bodyParser.json({ limit: "50mb" }));
|
||||
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
||||
//app.use(enforce.HTTPS({ trustProtoHeader: true }));
|
||||
app.use(cors());
|
||||
|
||||
//Test route to ensure Express is responding.
|
||||
app.get("/test", async function (req, res) {
|
||||
console.log("Incoming test request.", req);
|
||||
res.status(200).send("OK");
|
||||
});
|
||||
|
||||
app.post("/auth", fb.validateFirebaseIdToken);
|
||||
|
||||
app.get("/", async function (req, res) {
|
||||
|
||||
|
||||
res.status(200).send("Access Forbidden.");
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
app.listen(port, (error) => {
|
||||
if (error) throw error;
|
||||
console.log("AWS - [PRODUCTION] Server running on port " + port);
|
||||
});
|
||||
} else {
|
||||
app.listen(port, (error) => {
|
||||
if (error) throw error;
|
||||
console.log("[DEVELOPMENT] Non Secured Server running on port " + port);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user