Codeshelver is open source

15 views
Skip to first unread message

Dennis Blöte

unread,
Nov 8, 2010, 2:41:28 PM11/8/10
to expre...@googlegroups.com
Hey everyone,

a while ago I mentioned Codeshelver, an app I've written with express. Yesterday I open sourced it and I thought it might be of interest for some of you.

http://dennisbloete.de/blog/codeshelver-is-open-source/
http://github.com/dbloete/Codeshelver
http://codeshelver.com/

Best regards,
--
Dennis

web http://dennisbloete.de
mobil +49 (0)151 22630317

Ciaran

unread,
Nov 9, 2010, 4:28:56 AM11/9/10
to expre...@googlegroups.com
Cool, I notice you're using my OAuth2 implementation code there, you
might be better off using a sub-module so you get fixes automatically
when I apply them ?
-cj.

> --
> You received this message because you are subscribed to the Google Groups "Express" group.
> To post to this group, send email to expre...@googlegroups.com.
> To unsubscribe from this group, send email to express-js+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/express-js?hl=en.
>
>

Ciaran

unread,
Nov 9, 2010, 4:31:00 AM11/9/10
to expre...@googlegroups.com
oh and you can probably simplify your code by looking at
http://github.com/ciaranj/connect-auth which provides the github
connection stuff that you've had to implement...or even better feed
back improvements to the github strategy in there ?

Which would be cool :)
-cj.

dbloete

unread,
Nov 9, 2010, 4:23:17 PM11/9/10
to Express
Thanks for pointing that out, I updated the code to use the library
instead of the vendored version, I didn't know it was your lib, I just
found it on GitHub used in another project.

dbloete

unread,
Nov 9, 2010, 4:27:14 PM11/9/10
to Express
I just tried to use connect-auth but it broke stuff for me, maybe
because I'm using ndistro to install the dependencies? After
installing it via ndistro I had all the connect-auth files linked in
lib/node/… instead of lib/node/connect-auth (in a seperate folder,
like the other libs are doing it), maybe that broke it for me.

I got errors like res.cookie is undefined. How can we fix that?

Ciaran

unread,
Nov 9, 2010, 5:45:27 PM11/9/10
to expre...@googlegroups.com
On Tue, Nov 9, 2010 at 9:27 PM, dbloete <dbl...@gmail.com> wrote:
> I just tried to use connect-auth but it broke stuff for me, maybe
> because I'm using ndistro to install the dependencies? After
> installing it via ndistro I had all the connect-auth files linked in
> lib/node/… instead of lib/node/connect-auth (in a seperate folder,
> like the other libs are doing it), maybe that broke it for me.
Not sure, I've never used ndistro, but TJ is around, perhaps he may be
able to answer that Q.

>
> I got errors like res.cookie is undefined. How can we fix that?

An error like that means the strategy you're using has a dependency on
connect's session middleware (which in turn has a dependency on the
cookie middleware, install them and you're away :)

-cj

vision media [ Tj Holowaychuk ]

unread,
Nov 9, 2010, 10:35:48 PM11/9/10
to expre...@googlegroups.com
does connect-auth have external deps? otherwise this will do:

module senchalabs connect
module visionmedia express
module ciaranj connect-auth
--
Tj Holowaychuk
Vision Media
President & Creative Lead

Ciaran

unread,
Nov 10, 2010, 2:05:53 AM11/10/10
to expre...@googlegroups.com
If an oauth strategy is used, it requires npm's oauth. But that's all I believe

- cj

On Wednesday, November 10, 2010, vision media [ Tj Holowaychuk ]


<t...@vision-media.ca> wrote:
> does connect-auth have external deps? otherwise this will do:

> module senchalabs connectmodule visionmedia expressmodule ciaranj connect-auth

dbloete

unread,
Nov 11, 2010, 4:27:33 PM11/11/10
to Express

> > I got errors like res.cookie is undefined. How can we fix that?
>
> An error like that means the strategy you're using has a dependency on
> connect's session middleware (which in turn has a dependency on the
> cookie middleware, install them and you're away :)

I did that, but there seems to be a problem or interference with the
way Express sets cookies, this is the error I get:

res.cookie('user', JSON.stringify(userData), { path: '/', expires: new
^
TypeError: Object #<a ServerResponse> has no method 'cookie'
at /Users/dbloete/Sites/codeshelver/server.js:138:13
at IncomingMessage.<anonymous> (/Users/dbloete/Sites/codeshelver/
lib/node/node-oauth/lib/oauth2.js:67:9)
at IncomingMessage.emit (events:41:20)
at HTTPParser.onMessageComplete (http:107:23)
at Client.onData [as ondata] (http:848:27)
at IOWatcher.callback (net:494:29)
at node.js:772:9

Ciaran

unread,
Nov 12, 2010, 3:48:04 AM11/12/10
to expre...@googlegroups.com
Hmm well that error's something different, looks like the arguments
you're using in your callback aren't the ones you think they are, in
the case of a sucessful OAuth2 request the callback you provide will
receive 3 arguments:

function( error, result, response);

The first argument will always be null in the case of a sucessful
request, or an object literal representing the error in the failure
case, the second argument contains the data received from the server
as a string, and the third argument gives you direct access to the
underlying node ServerResponse object returned from the HTTP client
connection.

None of these objects has a meaningful notion of 'cookie' ... which I
suspect is the error you're seeing, could you point me at the code in
github, it may perhaps be a scope/typo error ?

Cheers!
-cj

dbloete

unread,
Nov 12, 2010, 3:47:43 PM11/12/10
to Express
> None of these objects has a meaningful notion of 'cookie' ... which I
> suspect is the error you're seeing, could you point me at the code in
> github, it may perhaps be a scope/typo error ?

You can see it here, it's line 139: https://github.com/dbloete/Codeshelver/blob/master/server.js

I don't know why it's not working anymore, because the Express
response object has the cookie method… maybe it's something else I'm
missing, but I didn't figure it out, yet.

Ciaran

unread,
Nov 13, 2010, 11:53:09 AM11/13/10
to expre...@googlegroups.com

The only thing I can speculate is that somehow your callback/closure
is inheriting some scope from inside the OAuth library (so the 'res'
variable isn't pointing at what you think it is) to test for this, add
some code after line 117 to assign 'res' to some new local variable
e.g. 'var selfres= res' Then at line 139 refer to selfres instead of
res see if that works... as a side note connect-auth does all this for
you (including creating that user object ;) )

Cheers
-cj.

dbloete

unread,
Nov 15, 2010, 7:31:49 AM11/15/10
to Express
Okay, I figured it out: The problem occures by installing express and
connect-auth with ndistro, because ndistro puts all of connect-auth's
file directly in lib/node. Because connect-auth itself contains an
express folder, the one from connect-auth overwrites the linked one
from express and so express isn't properly loaded.

In case my description of the problem is too poor to understand I made
a screenshot: http://img.ly/2rdH

I also posted an issue to connect-auth https://github.com/ciaranj/connect-auth/issues/issue/19

Please tell me if I have to provide you with more feedback on that.

vision media [ Tj Holowaychuk ]

unread,
Nov 15, 2010, 11:21:55 AM11/15/10
to expre...@googlegroups.com
hmm that should not be the case unless you do a require paths unshift, otherwise it should be fine

--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.

vision media [ Tj Holowaychuk ]

unread,
Nov 15, 2010, 11:22:08 AM11/15/10
to expre...@googlegroups.com
(in connect-auth)

Ciaran

unread,
Nov 15, 2010, 12:39:55 PM11/15/10
to expre...@googlegroups.com
bleh, I'll check.
-cj

On Mon, Nov 15, 2010 at 4:22 PM, vision media [ Tj Holowaychuk ]

Ciaran

unread,
Nov 15, 2010, 3:41:36 PM11/15/10
to expre...@googlegroups.com
OK a couple of things... that folder is legacy from the original port,
its not even used anymore so I can remove that, no biggy, but the
second thing is that I can't see any unshifts that would be relevant ?
:( .... anyho, I've removed it and pushed upstream and re-published on
npm, hope it helps :)
-cj

dbloete

unread,
Nov 16, 2010, 10:41:58 AM11/16/10
to Express
Okay, ndistro still links everything inside the lib/node folder, but
now it works, because it doesn't overwrite the express link anymore.

@TJ Why is that? I didn't really look into how ndistro works… why is
it linking the connect-auth files directly in lib/node?

My requires look like this:

require.paths.unshift(__dirname);
require.paths.unshift(__dirname + '/lib/node/');

var
express = require('express'),
OAuth2 = require('node-oauth').OAuth2,
auth = require('index');

It would be nice to do require('connect.auth') instead of
require('index') I think.


On 15 Nov., 21:41, Ciaran <ciar...@gmail.com> wrote:
> OK a couple of things... that folder is legacy from the original port,
> its not even used anymore so I can remove that, no biggy, but the
> second thing is that I can't see any unshifts that would be relevant ?
> :( .... anyho, I've removed it and pushed upstream and re-published on
> npm, hope it helps :)
> -cj
>
> On Mon, Nov 15, 2010 at 5:39 PM, Ciaran <ciar...@gmail.com> wrote:
> > bleh, I'll check.
> > -cj
>
> > On Mon, Nov 15, 2010 at 4:22 PM, vision media [ Tj Holowaychuk ]
> > <t...@vision-media.ca> wrote:
> >> (in connect-auth)
>
> >> On Mon, Nov 15, 2010 at 8:21 AM, vision media [ Tj Holowaychuk ]
> >> <t...@vision-media.ca> wrote:
>
> >>> hmm that should not be the case unless you do a require paths unshift,
> >>> otherwise it should be fine
>

vision media [ Tj Holowaychuk ]

unread,
Nov 16, 2010, 10:43:33 AM11/16/10
to expre...@googlegroups.com
because look looks relative to ../lib/node first for a module (at least pre 0.3.x it does) but seeing as ryan changes his mind ever other day im not sure about 0.3.x

so you should be able to get rid of those unshifts

dbloete

unread,
Nov 16, 2010, 4:41:45 PM11/16/10
to Express
Ok, thanks to both of you! :)


On 16 Nov., 16:43, "vision media [ Tj Holowaychuk ]" <t...@vision-
> > > >>>> express-js+...@googlegroups.com<express-js%2Bunsu...@googlegroups.com>
> > .
> > > >>>> For more options, visit this group at
> > > >>>>http://groups.google.com/group/express-js?hl=en.
>
> > > >>> --
> > > >>> Tj Holowaychuk
> > > >>> Vision Media
> > > >>> President & Creative Lead
>
> > > >> --
> > > >> Tj Holowaychuk
> > > >> Vision Media
> > > >> President & Creative Lead
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > Groups
> > > >> "Express" group.
> > > >> To post to this group, send email to expre...@googlegroups.com.
> > > >> To unsubscribe from this group, send email to
> > > >> express-js+...@googlegroups.com<express-js%2Bunsu...@googlegroups.com>
> > .
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/express-js?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Express" group.
> > To post to this group, send email to expre...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > express-js+...@googlegroups.com<express-js%2Bunsu...@googlegroups.com>
> > .

Ciaran

unread,
Nov 16, 2010, 5:31:51 PM11/16/10
to expre...@googlegroups.com
So are we all good on this now ? :)
-cj

> To unsubscribe from this group, send email to express-js+...@googlegroups.com.

dbloete

unread,
Nov 17, 2010, 10:36:31 AM11/17/10
to Express
I think so :)

Well, you could give me some best practice advice for connect-auth as
I'm sure I'm not doing it the best way, but there are no problems
anymore. If you like to, you can review the code here:
https://github.com/dbloete/Codeshelver/blob/master/server.js

Bye, Dennis

On 16 Nov., 23:31, Ciaran <ciar...@gmail.com> wrote:
> So are we all good on this now ? :)
> -cj
>

Christoph Jasinski

unread,
Nov 17, 2010, 11:17:44 AM11/17/10
to expre...@googlegroups.com
Great everyone. Big thanks!

Cheers,
Chris
Reply all
Reply to author
Forward
0 new messages