Giter Site home page Giter Site logo

bogart's People

Contributors

aaronshaf avatar bennlich avatar blakmatrix avatar dcolens avatar elwerene avatar fitzgen avatar jdavisclark avatar lpatters avatar malleor avatar mcsharps avatar nrstott avatar qm3ster avatar rhino-security avatar wijskinner avatar wmertens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bogart's Issues

Using socket.io with bogart

I've tried

app = bogart.start(router,{port:80});
io = io.listen(app);

and receive

Error: EADDRINUSE, Address already in use

Any ideas?

Normalize the signature of bogart.router to match that of other middleware

Currently bogart.router takes two paratmers, the first is a DSL configuration function that is run in the context of the router and the 2nd is the nextApp function which is called when there is no route to handle the current route.

bogart.router should be changed to match standard JSGI middleware.

It should function such that bogart.router returns a function that takes a nextApp. That nextApp will be available as this.nextApp perhaps to the route handlers to apply the russian doll model. req.nextApp is also an option.

Example:

var router = bogart.router();
router.get('/', function(req) {
   req.params['name'] = 'World';
   return this.nextApp(req);
});

bogart.start(router(function() {
  return function(req) {
    return {
      status: 200,
      body: [ 'Hello ' + req.params.name ],
      headers: { 'content-type': 'text/html' }
    };
  }
}));

Request:
GET / => 'Hello World'

JQuery ajax posts and gets only recognized some of the time?

This could definitely be an implementation problem on my end, as I'm still a novice, but it seems like my bogart app is not receiving my JQuery ajax posts and gets properly.

On the client:

function queryFunc() {
$.get("query", function(response) {} )
.error(function(response, text, error) {
console.log("---Ajax Error---");
console.log(response);
console.log(text);
console.log(error);
});
}

On the server:

var bogart = require('bogart');

var viewEngine = bogart.viewEngine('mustache'),
router = bogart.router();

router.get('/query', function(req) {
console.log("Received get request.");
return bogart.redirect('moose/moose/moose');
});

var app = bogart.app();
app.use(bogart.batteries);
app.use(router);
app.start(8970, '127.0.0.1');

The server console doesn't get logged every time I make the ajax request, and the redirect response never goes through. The client logs an empty error response Object every time I make a call to queryFunc(). However, if I point my browser directly to /query, the redirect works as expected. The problem is similar with $.post() and router.post().

bogart.batteries + zlib

middleware.js, line 67 has require("zlib") but zlib isn't setup as a dependency on the bogart npm package.

"Error: Cannot find module './deflate-bindings'"

Sorry to be a bother on this. Using the very latest bogart (0.3.7) I am still getting

Error: Cannot find module './deflate-bindings'

... when I run gzip-response.js.

I am on Ubuntu 11.04, bogart/node_modules/deflate is there, and I've successfully run build.sh in it.

Any ideas?

Running Bogart Apps on the same domain throws an error

I have 2 bogart apps running on the same domain and I a getting the following error:

An error occurred.

Message:

error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
Stack Trace:

TypeError: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
at Decipher.Cipher.final (crypto.js:287:27)
at Object.exports.decrypt (/sites/director-point/node_modules/bogart/lib/security.js:25:19)
at IdProvider.getSessionId (/sites/director-point/node_modules/bogart/lib/middleware/session/idProvider.js:27:23)
at /sites/director-point/node_modules/bogart/lib/middleware/session/session.js:50:32
at /sites/director-point/node_modules/bogart/lib/middleware/methodOverride.js:32:10
at /sites/director-point/node_modules/bogart/lib/middleware.js:21:14
at /sites/director-point/node_modules/bogart/lib/middleware/parted.js:25:14
at /sites/director-point/node_modules/bogart/lib/middleware/directory.js:97:16
at _fulfilled (/sites/director-point/node_modules/bogart/node_modules/q/q.js:703:54)
at self.promiseDispatch.done (/sites/director-point/node_modules/bogart/node_modules/q/q.js:732:30)

returning `undefined` from routers creates hard to understand behavior for beginners

When a developer forgets to return the result of a promise-returning function call in a Bogart router, there is no useful error. The error is Not found: /insert/route/here. This is because undefined is a valid return from a bogart router. The higher middleware, when batteries is included, is changing that to a 404 response.

However, this behavior is confusing, especially for newer users of Bogart.

It is important to keep the ability to return nothing for the use-case of writing middleware using routers; however, a new return should be indicated to signal intentionally empty.

This return could be a constant off of the bogart namespace or it could be null.

Handle OPTIONS

Can someone please add to README.md a short paragraph on how to handle OPTIONS HTTP requests.

Question: How to send a cookie?

Hi,

I've tried to figure this out myself with no luck so far so can someone please help me understand how to send a cookie e.g. 'foo'='bar'. In the meantime I suppose I proxy to http and try setting the cookie there but it seems a bit of a waste.

BTW: In my efforts to try and figure it out, I see a lot of references to flash cookies but was unable to get supporting info from the web (also sorting it from adobe's flash made things harder). Same thing regarding JSGI where most info is understandable by those who already understand, not a noob like myself. Therefore, any suggestions for sources to help it sink in would be appreciated.

If this is not the correct place to be asking this type of question I apologize. If so, please direct me to where it would be more appropriate.

Many thanks!

Change Bogart Middleware to permit calling the function to receive the middleware factory

In addition to supporting passing the function as a first-class parameter to form a middleware chain, make bogart middleware support calling it as a factory for returning the JSGI middleware.

Example:

app.use(bogart.middleware.parted); // current
app.use(bogart.middleware.parted()); // enhanced

This will permit middleware that requires parameters to be called more intuitively.

app.use(bogart.middleware.session, sessionConfig); // current
app.use(bogart.middleware.session(sessionConfig)); // enhanced

text/cache-manifest mimetype

According to http://diveintohtml5.info/offline.html, html5 .manifest files should be served with a text/cache-manifest mimetype. I've had no trouble serving .manifest's with Bogart to Firefox, Safari, and Chrome, but I notice there is no mimetype for .manifest listed in lib/mimetypes.js. Maybe it should be added? Doesn't seem to be causing any problems though.

bogart truncates returned html

Many of the files that my "return bogart.html(article);" is serving up are truncated.

When I alternatively use:

return {
    status: 200,
    body: [article],
    headers: { "content-type": "text/html", "content-length": article.length + 10 }
};

... substituting "10" for whatever you like, the web site response to the browser returns more text of "article", etc.

Can't load partial when using mustache view engine

Hi,

I'm trying to load a partial into my main mustache template but fail with this message in the browser:

unknown_partial 'home_button.html'

My main template, index.html, looks like this:

<div>{{> home_button }}</div>

According to the mustache documentation I shouldn't need to add an extension, but I also tried {{> home_button.html }} and had no luck. My two template files live in the 'templates' directory. Any idea what I'm doing wrong?

Thanks,
Luke

ps: here's how I set up my bogart app

var bogart = require('bogart'),
    path = require('path');

var app = bogart.router(function(get, post, put, del) {
  var viewEngine = bogart.viewEngine('mustache', path.join(__dirname, 'templates'));
  get('/', function(req) {
    return viewEngine.respond('index.html');
  });

/* ... snip ...*/

Lost in the promised land: can't respond with bogart.res.

Hi,

I cannot send a response with the following:

This is the terminal output:
Trying to log in as barney
Posting to sessiondb , returned: '{"ok":true,"name":"barney","roles":["properties_reader"]}\n'
Success posting to session, returned AuthSessionAuthSession=YmFybmV5OjUxQkU1OTQ5Og7SxuLAcrLru-0aTPofOKno6-FR,Authrole=properties
reader
Testing credentials using cookie YmFybmV5OjUxQkU1OTQ5Og7SxuLAcrLru-0aTPofOKno6-FR
testCredentials: success

And the code goes like:
router.post('/authenticate', function(req) {
//post to couchdb with params.user/pswd to _sessions to get an AuthSession
return when(getResponse(options), function(response){
//get the AuthSession cookie, set req.session.authSession
//test the user against the target database
return when(testCredentials(options, req.session("AuthSession")), function(response){
})
}).then(function(){
var res = bogart.res();
res.status = 302;
res.headers = { "location": 'http://www.google.com'};
res.body = [];
res.end();
return res;
})
})

I never get a response.

What am I doing wrong?

Feature Request: Bogart Server Side Caching

It'd be nice to be able to have an option on the route to specify how long to cache server side for and whether or not to vary by param etc.

This could have memory leak implications. I'm not sure how you take those out of the programmers hands though unless you outsourced the actual cache to redis or something.

Supporting jade includes

The jade template engine requires the variable filename to be set to the absolute path of the template file in order for includes to work right.

It's possible to achieve this within a route handler...

router.get('/', function() {
     return viewEngine.respond('index.jade', { filename: path.join(__dirname,'/views/index.jade')  });
 });

...but that's kind of a pain. This could be solved a number of ways, but one way it can't is in the jade adapter. As implemented, bogart doesn't pass this information back to the template engine so when jade is added as a template engine it's rendering function can't automatically handle this.

As a solution to this, the viewEngine could pass the viewPath (along with the view and whatever else) back to the template engine for those engines that need it. I forked bogart and implemented this on my fork as a 5th parameter on the engine callback.

Where it was function(template, opts, cache, viewEngine)

It is now function(template, opts, cache, viewEngine, meta)

Does this sound like a solution that makes sense or is there a better approach?

https://github.com/tstone/bogart/commit/0df477cd822bc02ccaacf240657ca1d265df383f
https://github.com/tstone/bogart-jade/commit/5f9d943450d06f43e61ed7974d56feb131652e28

router.before/after callback promise support

Routing callbacks registered with before/after are currently executed without respect for any possible returned promises. We probably need shove the return values of all the before/after callbacks in to arrays and wait for a 'q.all' to resolve in the appropriate places.

Also, the 'after' callbacks should probably be executed after the promise from the call to "route.handler.apply" is resolved.

Thoughts?

Getting a crypto error after upgrading node to v0.10.20

This is printed to my browser window when trying to navigate to a page hosted by the server:

An error occurred.Cannot change encoding

Stack Trace:
AssertionError: Cannot change encoding at getDecoder (crypto.js:241:3) at Decipher.Cipher.final (crypto.js:290:21) at Object.exports.decrypt (/Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/bogart/lib/security.js:25:19) at CookieDataProvider.previousFlash (/Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/bogart/lib/flash/flashCookieDataProvider.js:18:25) at /Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/bogart/lib/middleware.js:392:62 at /Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/bogart/lib/session/session.js:25:25 at exports.when (/Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/promised-io/promise.js:348:29) at /Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/bogart/lib/session/session.js:24:16 at /Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/bogart/lib/middleware.js:126:16 at /Volumes/Macintosh HD/Users/bennlich/Documents/Node/cityknowledge/node_modules/bogart/lib/middleware.js:140:20

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.