Make bootstrap.zip accessible via GET #4

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+19 −10
Split
View
@@ -23,6 +23,7 @@ var express = require('express')
, zip = require('node-native-zip')
, app = express.createServer()
, types = {}
+ , downloadHandler
types.img = require('./lib/img')
types.js = require('./lib/js')
@@ -49,19 +50,24 @@ app.get('/', function (req, res) {
res.send('Bootstrap Server - w/cache. <3');
})
-app.post('/', function(req, res) {
+downloadHandler = function downloadHandler(req, res) {
var dist = []
, started = 0
, params = {}
, archive = new zip()
- params.js = req.body.js && JSON.parse(req.body.js)
- params.css = req.body.css && JSON.parse(req.body.css)
- params.img = req.body.img && JSON.parse(req.body.img)
- params.vars = req.body.vars && JSON.parse(req.body.vars)
+ params.js = req.query.js || req.body.js
+ params.css = req.query.css || req.body.css
+ params.img = req.query.img || req.body.img
+ params.vars = req.query.vars || req.body.vars
+
+ Object.keys(params).forEach(function (type) {
+ if (!params[type] || params[type].length === 0) return
+ params[type] = JSON.parse(params[type])
+ })
Object.keys(types).forEach(function (type) {
- if (!params[type] || !params[type].length) return
+ if (!params[type] || params[type].length === 0) return
types[type](params, complete)
})
@@ -71,6 +77,9 @@ app.post('/', function(req, res) {
res.attachment('bootstrap.zip')
res.send(archive.toBuffer())
-})
+}
+
+app.post('/', downloadHandler)
+app.get('/bootstrap.zip', downloadHandler)
app.listen(process.env.PORT || 3000)
View
@@ -1,11 +1,11 @@
{
"name": "bootstrap-server"
, "description": "a build tool for bootstrap"
- , "version": "1.0.0"
+ , "version": "1.0.1"
, "engines": { "node": "0.6.20" }
, "main": "web.js"
, "dependencies": {
- "express": "2.5.5"
+ "express": "2.5.x"
, "uglify-js": "1.2.4"
, "less": "1.3.3"
, "node-native-zip": "1.0.1"
@@ -16,4 +16,4 @@
, "url": "https://github.com/twitter/bootstrap-server.git"
}
, "licenses": [ { "type": "Apache-2.0" , "url": "http://www.apache.org/licenses/LICENSE-2.0" } ]
-}
+}