-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (40 loc) · 1.03 KB
/
app.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
45
const express = require('express');
const app = express();
const marked = require('marked');
const hljs = require('highlight.js');
const cors = require('cors');
const pageRoutes = require('./routes/pages/index');
marked.setOptions({
highlight: function (code, lang) {
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
return hljs.highlight(code, { language }).value;
},
baseUrl: null,
breaks: true,
extensions: null,
gfm: true,
headerIds: true,
headerPrefix: '',
langPrefix: 'hljs language-',
mangle: true,
pedantic: false,
sanitize: false,
sanitizer: null,
silent: false,
smartLists: false,
smartypants: false,
tokenizer: null,
walkTokens: null,
xhtml: false,
});
app.use(cors());
app.use(express.static('dist'));
// app.use(express.static('posts'));
app.options('*', cors());
app.use('/', pageRoutes); //for SSR frontend
if (process.env.NODE_ENV === 'production') {
app.listen(4000, function () {
console.log('Server started. Go to http://localhost:4000/');
});
}
module.exports = app;