-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (36 loc) · 1014 Bytes
/
index.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
42
43
44
'use strict';
const winston = require('winston');
const fs = require('fs');
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
var app = express();
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
timestamp: true,
prettyPrint: true,
colorize: true,
}),
]
});
// Serve assets in /public.
app.use(express.static(__dirname + '/public'));
// So we can POST.
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true
}));
// Since Mixmax calls this API directly from the client-side, it must be whitelisted.
var corsOptions = {
origin: /^[^.\s]+\.mixmax\.com$/,
credentials: true
};
// The editor interface.
app.get('/editor', function(req, res) {
res.sendFile(__dirname + '/public/index.html');
});
// The in-email representation.
app.post('/api/resolver', cors(corsOptions), require('./api/resolver'));
app.listen(process.env.PORT || 8910);