UNPKG

561 Btext/coffeescriptView Raw
1express = require 'express'
2fs = require 'fs'
3
4class Server
5 constructor: ( @site ) ->
6 @app = express.createServer(
7 Config.DEBUG && express.logger( format: Logger._fmt( 'info' ) + " :method :url :status" ),
8 ( req, res, next ) ->
9 fs.stat "build/#{req.url}", ( err, stat ) ->
10 if err || stat.isDirectory()
11 req.url += '/'
12 next()
13 express.static("#{@site.root}/build")
14 )
15 start: () ->
16 @app.listen Config.PORT
17 Logger.info "DEV :: Server listening on :#{Config.PORT}"
18
19module.exports = Server