Skip to content

Instantly share code, notes, and snippets.

@mlebkowski
Created February 14, 2014 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlebkowski/8999459 to your computer and use it in GitHub Desktop.
Save mlebkowski/8999459 to your computer and use it in GitHub Desktop.
Bless as a Service
var express = require("express");
var logfmt = require("logfmt");
var parser = require('bless').Parser;
var app = express();
app.use(logfmt.requestLogger());
app.post('/:name.css', function(request, response) {
response.writeHead(200, {'Content-Type': 'application/json'});
var bless = new parser({
"output": request.params.name + ".css",
"options": request.query
});
var cssData = "";
request.on('data', function (data) { cssData += data; });
request.on('end', function () {
bless.parse(cssData, function (error, files, numSelectors) {
response.end(JSON.stringify({
"error": error,
"files": files,
"numSelectors": numSelectors
}));
});
});
});
var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
console.log("Listening on " + port);
});
{
"name": "baas",
"version": "1.0.0",
"description": "BlessCSS as a Service",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Maciej Łebkowski <m.lebkowski@gmail.com>",
"license": "BSD",
"dependencies": {
"bless": "~3.0.3",
"logfmt": "~0.21.0",
"express": "~3.4.8"
},
"engines": {
"node": "0.10.x"
}
}
web: node index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment