forked from hibiyasleep/azu-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.coffee
64 lines (47 loc) · 1.34 KB
/
app.coffee
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env coffee
sassMiddleware = require 'node-sass-middleware'
serveStatic = require 'serve-static'
bodyParser = require 'body-parser'
session = require 'express-session'
express = require 'express'
moment = require 'moment'
ejs = require 'ejs'
fs = require 'fs'
config = require './config.json'
routes = require './routes'
app = express()
app.locals =
static: config.static
baseuri: config.baseuri
login_uri: config.login
app.get '/*', (req, res, next) ->
res.set 'X-XSS-Protection', 0
res.set 'Cache-Control', 'max-age=0'
next()
app.set 'view engine', 'ejs'
app.use sassMiddleware
src: __dirname
dest: __dirname
indentedSyntax: true
sourceMap: true
prefix: '/!'
app.use session
secret: '64KY64qUIOywqe2VmOuLpAo='
app.use bodyParser bodyParser.urlencoded extended: true
app.use '/!/public', serveStatic __dirname + '/public'
app.get '/', (req, res) -> res.render 'index'
routes app
# listen
if typeof config.listen is 'string'
c = () ->
app.listen config.listen
fs.chmod config.listen, '777', () ->
console.log 'Now listening on ' + config.listen
fs.access config.listen, (error) ->
if error
c()
else
fs.unlink config.listen, c
else
app.listen config.listen
console.log 'Now listening on ' + config.listen