Website about Keiji Yoshida
Installation
$ go get -u github.com/yosssi/yoss.si
Execution
$ MARTINI_ENV=production yoss.si
Stylus middleware for Koa
License: MIT License
$ go get -u github.com/yosssi/yoss.si
$ MARTINI_ENV=production yoss.si
TypeError: middleware must be a function!
Please, update npm package
Hello,
When I try to use a custom compile function, the script ends without any error message. My code is:
app.use(stylus({
src: path.resolve('./stylus'),
dest: path.resolve('./public'),
compile: function(str, path) {
return stylus(str)
.set('filename', path)
.set('compress', true)
.use(nib());
}
}));
app.use(koaStatic('./public'));
The output I am getting:
[buzz@megazord backend]$ node src/server.js
server /home/buzz/Projetos/mobtag/backend/stylus +0ms
server Application server listening to port 3000 +2ms
<-- GET /
--> GET / 200 583ms 1.74kb
<-- GET /css/font-awesome.min.css
--> GET /css/font-awesome.min.css 304 8ms
<-- GET /mobtag.css
[buzz@megazord backend]$
I already isolated the problem to the custom compile function, but I as of now I am stuck :-(
Could you please check the following code:
/**
* @param {object} options
* @returns {Function}
*/
function koaStylus(options) {
const middleware = stylus.middleware(options);
function compile(req, res) {
return callback => {
middleware(req, res, callback);
};
}
return async function stylusMiddleware(ctx, next) {
compile(ctx.req, ctx.res);
return await next();
};
}
This works.. I think. But could someone please explain how it works? What does calling compile do? It just returns a function right? How does that end up executing stylus middleware?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.