mikeal / tako Goto Github PK
View Code? Open in Web Editor NEWFunctional web framework.
Functional web framework.
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.
Since we did not receive a CI status on the greenkeeper/initial
branch, we assume that you still need to configure it.
If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/
.
We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.
I'm totally enjoying work with tako
. I found that you didn't implement the redirect
method in the resp
.
For the moment I'm doing this:
resp.redirect = function(url, status) {
resp.statusCode = 302
resp.setHeader('Location', url)
resp.end()
}
And it's working, but I feel like there is a lot of more options to implement in this method (not an expert), Also I didn't found a bodyParser for inconming request. That will be handy.
I'm really looking forward for it, for this implementation.
Cheers.
tldr; really liked what the tako example looked like, tried it out, couldn't figure out a good way to serve a 404 page, couldn't figure out how to have static files in sub-folders get served.
Hey Mikeal,
Some things that happened when I tried to use tako for my static site:
PUBLIC = path.join(__dirname, 'public')
app.route('/').files(PUBLIC)
/public
are not correctly found & served by filedapp.notfound.html = path.join(PUBLIC, '404.html');
And in app.notfound:
@@ -437,10 +437,16 @@ Application.prototype.notfound = function (req, resp) {
resp.setHeader('content-type', cc)
if (cc === 'text/html') {
body = '<html><body>Not Found</body></html>'
+ if (this.notfound.html) return filed(this.notfound.html).pipe(resp)
} else if (cc === 'application/json') {
body = JSON.stringify({status:404, reason:'not found', message:'not found'})
} else {
body = 'Not Found'
+ if (this.notfound.html) {
+ resp.setHeader('content-type', 'text/html')
+ console.log('fugg', this.notfound.html, resp.getHeader('content-type'))
+ return filed(this.notfound.html).pipe(resp);
+ }
}
resp.end(body)
}
/Users/maxogden/src/bro/node_modules/tako/handlebars.js:288
throw new Error(str);
^
Error: Lexical error on line 1. Unrecognized text.
after debugging and figuring out handlebars was trying to evaluate a .DS_Store file i deleted it and the server started up normally
The current tako version being pulled via npm doesn't match the github repo. Version is "0.2.5" as opposed to "0.2.4" and socket.io is being installed by default again.
I had a simple static fileserver, just like in the example:
tako = require('tako');
app = tako();
app.route('*').files(require('path').join(__dirname, 'public'));
app.httpServer.listen(9999);
The query for something...
curl localhost:9999/something.txt
... will now be redirected to...
./public/something.txt/
... and not obviously not found there.
I changed the mapleTree version from * to 0.2.x to fix this.
Through #16 an error was introduced.
When no content-type headers are send.
var request = require('request');
request.put(uri, fn); // will not set content-type headers
Some basic session handling would be good. Not anything like Express's in-memory sessions, or some kind of fancy pants pluggable session, but just the most basic possible token management.
app.sessionKey = value
This would enable the behavior. The configuration could be gotten from wherever, or even just set randomly.app.sessionKey
, then set request.session = cookies[app.sessionKey]
app.sessionKey
, then set a response.headers['set-cookie'] so that it'll be set to a random string (like require("crypto").randomBytes(30).toString("base64")
or something).Then, it's up to the app to know what to do with this token, what it means, etc. It could be a key to some in-memory store, or a redis doohickey, or the name of another cookie that they'll set the actual data in, etc.
How adding helpers using Handlebars.registerHelper() is exposed in tako?
For GET requests, it should be the same as route.html(). For PUTs and POSTs, however, it also accepts application/x-www-url-encoded (in which case it'll be buffered and parsed), or multipart/form-data
, in which case it will run it through formidable or something.
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.
Since we did not receive a CI status on the greenkeeper/initial
branch, we assume that you still need to configure it.
If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/
.
We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.
So, right now, middleware can do this:
middleware.on("request", function (req, res) {
res.onWrite = function (chunk) {
// do something, and return a different chunk synchronously
}
})
however, there's no way to:
Really, what you want to do is hijack the actual request/response with a filter of some sort.
For example, a gzip middleware might conditionally want to attach a decoding filter onto the request, and an encoding filter onto the response.
Consider this:
gzipMiddleware.on("request", function (req, res) {
// attach a filter in front of the readable request stream.
// Methods proxied: pipe, pause, resume
// .on() attaches listeners to filter instead for: data, end, close
if (requestCompressed(req)) req.filter = zlib.Unzip()
// attach a filter in front of the writable response stream.
// Methods proxied: write, end
// .on() attaches listeners to filter instead for: pause, resume
if (responseCanBeCompressed(req)) res.filter = zlib.Gzip()
})
t.templates.directory(path.resolve(__dirname, '..', 'templates'))
loads every file in the ./templates
folder but I'd like to say:
t.templates.directory(path.resolve(__dirname, '..', 'attachments'), /*.mustache/)
or whatever so I can use the same folder for static assets + templates
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.