Skip to content

Commit

Permalink
feat(express): use middleware body-parser to parse application/json
Browse files Browse the repository at this point in the history
  • Loading branch information
jyounce committed Aug 13, 2015
1 parent 23f4483 commit 2e635da
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/config-node_modules.coffee
Expand Up @@ -5,7 +5,7 @@ module.exports = (config, options) ->

# modules
# =======
rbModules = ['express']
rbModules = ['express', 'body-parser']
appModules = options.server.node_modules or []

# http proxy
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
"conventional-changelog": "~0.0.17"
},
"dependencies": {
"body-parser": "~1.13.3",
"bower": "~1.4.1",
"browser-sync": "~2.8.2",
"coffee-script": "~1.9.3",
Expand Down
5 changes: 5 additions & 0 deletions src/server/server.coffee
@@ -1,6 +1,7 @@
dir = __dirname # all paths are relative to this file
path = require 'path'
express = require 'express'
bodyParser = require 'body-parser'
config = require path.join dir, 'config.json'
app = express()
port = process.env.PORT or config.ports.server
Expand All @@ -10,7 +11,11 @@ appFilePath = path.resolve dir, '..', config.dist.app.server.scripts.file
serverDirPath = path.resolve dir, '..', '..', config.dist.app.server.dirName
proxyFilePath = path.join dir, 'http-proxy.js'

# configure
# =========
app.use express.static clientDirPath
app.use bodyParser.json() # parse application/json

app.listen port, ->
console.log "#{config.server.msg.start} #{config.ports.server}"

Expand Down

0 comments on commit 2e635da

Please sign in to comment.