BOD-69 Testing out code for Cloudinary + swapping out resizer.
This commit is contained in:
31
server.js
31
server.js
@@ -11,8 +11,8 @@ const https = require("https");
|
||||
const fs = require("fs");
|
||||
|
||||
const app = express();
|
||||
//const port = process.env.PORT || 5000;
|
||||
const port = 5000;
|
||||
const port = process.env.PORT || 5000;
|
||||
//const port = 5000;
|
||||
|
||||
app.use(compression());
|
||||
app.use(bodyParser.json());
|
||||
@@ -20,18 +20,20 @@ app.use(bodyParser.urlencoded({ extended: true }));
|
||||
//app.use(enforce.HTTPS({ trustProtoHeader: true }));
|
||||
app.use(cors());
|
||||
|
||||
var s3upload = require("./s3upload");
|
||||
app.post("/sign_s3", s3upload.sign_s3);
|
||||
app.get("/sign_s3", s3upload.get_s3);
|
||||
app.post("/delete_s3", s3upload.delete_s3);
|
||||
|
||||
//Email Based Paths.
|
||||
var sendEmail = require("./sendemail.js");
|
||||
app.post("/sendemail", sendEmail.sendEmail);
|
||||
|
||||
app.get("/test", function(req, res) {
|
||||
//Test route to ensure Express is responding.
|
||||
app.get("/test", function (req, res) {
|
||||
res.json({ success: true });
|
||||
});
|
||||
|
||||
//Cloudinary Media Paths
|
||||
var media = require("./server/media/media");
|
||||
app.post("/media/upload", media.createSignedUploadURL);
|
||||
|
||||
//SMS/Twilio Paths
|
||||
var smsReceive = require("./server/sms/receive");
|
||||
app.post(
|
||||
"/sms/receive",
|
||||
@@ -47,12 +49,11 @@ app.post(
|
||||
smsStatus.status
|
||||
);
|
||||
|
||||
var downloadImages = require("./download-images");
|
||||
app.get("/downloadImages", downloadImages.downloadImages);
|
||||
|
||||
//Handlebars Paths for Email/Report Rendering
|
||||
var renderHandlebars = require("./server/render/renderHandlebars");
|
||||
app.post("/render", renderHandlebars.render);
|
||||
|
||||
//Serve React App if in Production
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
app.use(express.static(path.join(__dirname, "client/build")));
|
||||
|
||||
@@ -60,13 +61,13 @@ if (process.env.NODE_ENV === "production") {
|
||||
res.sendFile(path.resolve(__dirname, "..", "build", "service-worker.js"));
|
||||
});
|
||||
|
||||
app.get("*", function(req, res) {
|
||||
app.get("*", function (req, res) {
|
||||
res.sendFile(path.join(__dirname, "client/build", "index.html"));
|
||||
});
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
app.listen(port, error => {
|
||||
app.listen(port, (error) => {
|
||||
if (error) throw error;
|
||||
console.log("[PRODUCTION] Server running on port " + port);
|
||||
});
|
||||
@@ -76,11 +77,11 @@ if (process.env.NODE_ENV === "production") {
|
||||
{
|
||||
key: fs.readFileSync("./key.pem"),
|
||||
cert: fs.readFileSync("./cert.pem"),
|
||||
passphrase: "Wl0d8k@!"
|
||||
passphrase: "Wl0d8k@!",
|
||||
},
|
||||
app
|
||||
)
|
||||
.listen(port, error => {
|
||||
.listen(port, (error) => {
|
||||
if (error) throw error;
|
||||
console.log("[DEV/STAGING] Mock HTTPS Server running on port " + port);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user