-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (34 loc) · 855 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";
const express = require("express");
const http = require("http");
const bodyParser = require('body-parser');
const juice = require('juice');
if (process.env.SENTRY_DSN) {
console.log('Initiating sentry');
const Sentry = require("@sentry/node");
Sentry.init({
dsn: process.env.SENTRY_DSN
});
}
const app = express()
app.use(bodyParser.text());
app.post("/inline-css", (req, res) => {
let result = "";
try {
result = juice(req.body);
}
catch (e) {
if (Sentry) {
Sentry.captureException(e);
}
console.log(e)
}
res.set('Content-Type', 'text/html');
res.send(result)
});
app.get("/ht", (req, res) => {
res.json({ status: "OK" });
});
const httpServer = http.Server(app);
const PORT = process.env.PORT || 3000;
httpServer.listen(PORT, () => console.log(`Client Listening on ${PORT}`));