Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Noob Question

Received: by 10.100.21.2 with SMTP id 2mr8690140anu.51.1279022585444;
        Tue, 13 Jul 2010 05:03:05 -0700 (PDT)
X-BeenThere: express-js@googlegroups.com
Received: by 10.101.208.33 with SMTP id k33ls927004anq.0.p; Tue, 13 Jul 2010 
	05:03:04 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.101.27.36 with SMTP id e36mr890737anj.34.1279022584918; Tue, 
	13 Jul 2010 05:03:04 -0700 (PDT)
Received: by y4g2000yqy.googlegroups.com with HTTP; Tue, 13 Jul 2010 05:03:04 
	-0700 (PDT)
Date: Tue, 13 Jul 2010 05:03:04 -0700 (PDT)
In-Reply-To: <da6de770-b763-4f5e-845f-640e94bfb8ef@b35g2000yqi.googlegroups.com>
X-IP: 81.187.108.206
References: <0d27ce4f-72b3-4f6e-82b2-899e3d633a07@y4g2000yqy.googlegroups.com> 
	<2fb6343f-c00d-4b57-8075-38bd341a8cec@x21g2000yqa.googlegroups.com> 
	<AANLkTikDIKesQ-iaZjMM3zr-Dv2VKxixPNnTwQRR97cV@mail.gmail.com> 
	<A7553ABD-0C0F-4CFF-98C7-60910DA87BB8@dennisbloete.de> <AANLkTiled_uB5p3eeZXCgHoO6Xr-L44kH4Co924lM3Xd@mail.gmail.com> 
	<AANLkTinJ5PJkNpeFgLeie9sLy-oHr-mI7SVe7WQxpSmo@mail.gmail.com> 
	<8cccf6d1-e6bc-4ddb-969e-f227ef8bbd1e@t10g2000yqg.googlegroups.com> 
	<AANLkTim9uUXSqYwp3kGrVkh3qzrU_3ekpDlxOdtjAncw@mail.gmail.com> 
	<AANLkTin4elJMjmZEi-oykIC8tjj1-1yQ7xDDEVlIYbO_@mail.gmail.com> 
	<AANLkTimb9RE7j-eCYO5DsrEUnanaUEm8T0jRL2sGFTdF@mail.gmail.com> 
	<768eed70-20e4-4cbd-9f08-c11ebcc35173@r27g2000yqb.googlegroups.com> 
	<AANLkTinmKpDIrLnU_EnR_T6vLM-ojqxHvNkBUkgr7QE0@mail.gmail.com> 
	<da6de770-b763-4f5e-845f-640e94bfb8ef@b35g2000yqi.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) 
	AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4,gzip(gfe)
Message-ID: <36984a3a-557c-4743-abc7-e23eeeb72b1b@y4g2000yqy.googlegroups.com>
Subject: Re: Noob Question
From: Sammaye <sam.mill...@gmail.com>
To: Express <express-js@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

How can I attach a function to run on response in express?

so I want saveSession to run when response begins, basically at the
end of the script.

Is there an easy way of doing this?

I know the built in session class does this but I can't use that since
my sessions are quite customised and need some special functions and
behaviour that meant writing a new class was easier.

On Jul 10, 9:52=A0pm, Sammaye <sam.mill...@gmail.com> wrote:
> Ahhh lol cheers.
>
> On Jul 10, 9:43=A0pm, Aaron Heckmann <aaron.heckm...@gmail.com> wrote:
>
>
>
> > you just need to call `this.cookie` inside of a route:
>
> > get("/", function(){
> > =A0 this.cookie("totallyworks!")
>
> > })
> > On Sat, Jul 10, 2010 at 2:50 PM, Sammaye <sam.mill...@gmail.com> wrote:
> > > I got yet another problem.
>
> > > I've been looking through the doc and that but I still cannot seem to
> > > get cookies to work.
>
> > > I have got this:
>
> > > require("express/plugins");
>
> > > configure(function(){
> > > =A0 =A0 =A0 =A0use(MethodOverride);
> > > =A0 =A0 =A0 =A0use(Cookie);
> > > =A0 =A0 =A0 =A0use(ContentLength);
> > > =A0 =A0 =A0 =A0set('root', __dirname);
> > > });
>
> > > this.cookie("sx");
> > > this.cookie("sx", "sx", opts);
>
> > > But node.js just returns an error for either of the this.cookie lines=
.
> > > I cannot seem to get my head around how to use the cookie extension. =
I
> > > look through the docs and even the code to no avail.
>
> > > According to the code that line should work but it doesn't.
>
> > > On Jul 8, 12:08 pm, Sam Millman <smill...@nhbs.co.uk> wrote:
> > > > Ah yes that does it thanks :)
>
> > > > On 8 July 2010 12:07, Ciaran <ciar...@gmail.com> wrote:
>
> > > > > inside a route 'this' refers to the request object, the request o=
bject
> > > > > contains a property 'response' so:
>
> > > > > so this.response.setCookie() etc.
>
> > > > > Does that help?
>
> > > > > -cj.
>
> > > > > On Thu, Jul 8, 2010 at 12:05 PM, Sam Millman <sam.mill...@gmail.c=
om>
> > > > > wrote:
> > > > > > And again,
>
> > > > > > how can I get an object of the response?
>
> > > > > > I can do this.whatever for request but if I want to do
> > > > > response.setCookies()
> > > > > > what would I do for that?
>
> > > > > > I do notice in the examples that this context can also be used =
to set
> > > the
> > > > > > content type within reponse headers? can this context be used t=
o
> > > access
> > > > > > response methods like response.setCookies?
>
> > > > > > On 8 July 2010 09:09, Sammaye <sam.mill...@gmail.com> wrote:
>
> > > > > >> Yet another question :)
>
> > > > > >> Does SSJS or specifically node have strong inheritance.
>
> > > > > >> I have two files:
>
> > > > > >> app.js
> > > > > >> session.js
>
> > > > > >> Within my app.js I include a mongo db class but I use it withi=
n
> > > > > >> session.js.
>
> > > > > >> Both are required into app.js like:
>
> > > > > >> var mongo =3D require("mongo"),
> > > > > >> =A0 =A0 session =3D require("session");
>
> > > > > >> Can SSJS detect that session should have access to the same
> > > namespace
> > > > > >> as app.js or do I need to make the mongo object again within t=
he
> > > > > >> session class?
>
> > > > > >> On Jul 7, 3:57 pm, Josef Salyer <josef.sal...@gmail.com> wrote=
:
> > > > > >> > awesome!! =A0Looking forward to the new version!
>
> > > > > >> > On Wed, Jul 7, 2010 at 8:33 AM, vision media [ Tj Holowaychu=
k ]
>
> > > > > >> > <t...@vision-media.ca> wrote:
> > > > > >> > > Hopefully late next week. The site / man pages will be gen=
erated
> > > > > from
> > > > > >> > > markdown in the master branch so it will
> > > > > >> > > be easier for contributors as well :)
>
> > > > > >> > > On Wed, Jul 7, 2010 at 7:12 AM, Dennis Bl=F6te <
> > > m...@dennisbloete.de>
> > > > > >> > > wrote:
>
> > > > > >> > >> @TJ When do you plan to release 1.0? As I said I'd like t=
o help
> > > > > with
> > > > > >> > >> the
> > > > > >> > >> documentation, in this case I'll wait for 1.0 and see wha=
t's
> > > > > missing
> > > > > >> > >> when
> > > > > >> > >> you publish the new site.
>
> > > > > >> > >> Am 07.07.2010 um 16:07 schrieb vision media [ Tj Holowayc=
huk ]:
>
> > > > > >> > >> > 1.0 will have better docs :) I am making sure if this l=
ol
> > > more /
> > > > > >> > >> > better
> > > > > >> > >> > docs. I will be removing the old
> > > > > >> > >> > site and replacing it, along with removing the wiki pag=
es,
> > > and
> > > > > >> > >> > clearing
> > > > > >> > >> > out all the issues
>
> > > > > >> > >> > On Wed, Jul 7, 2010 at 6:41 AM, Sammaye <
> > > sam.mill...@gmail.com>
> > > > > >> > >> > wrote:
> > > > > >> > >> > That is awesome. I'm getting the jist of the framework =
now
> > > and I
> > > > > >> > >> > had
> > > > > >> > >> > to learn thrift for cassandra so it's not that bad. Jus=
t in
> > > case
> > > > > >> > >> > you
> > > > > >> > >> > havent installed thrift before it's documentation is in=
stall
> > > > > >> > >> > instructions (which didn't work for me so I had install=
 it
> > > > > >> > >> > manually).....and that's it!!!
>
> > > > > >> > >> > Though don't put the code as white text on dark backgro=
und
> > > and
> > > > > very
> > > > > >> > >> > wordy like node.js, their documentation hurts my eyes a=
nd
> > > > > fatigues
> > > > > >> > >> > me
> > > > > >> > >> > easily :(.
>
> > > > > >> > >> > On Jul 7, 2:26 pm, Dennis Bl=F6te <m...@dennisbloete.de=
>
> > > wrote:
> > > > > >> > >> > > Hello everyone,
>
> > > > > >> > >> > > > There isn't more documentation :(
>
> > > > > >> > >> > > I'm currently working on a project that uses some of =
the
> > > > > >> > >> > > undocumented
> > > > > >> > >> > > features/plugins of express (i.e. flash, cookie, sess=
ion,
> > > > > hooks)
> > > > > >> > >> > > and I am
> > > > > >> > >> > > looking forward to add documentation for these when I=
 got
> > > the
> > > > > >> > >> > > project out
> > > > > >> > >> > > the door, because I had a hard time finding out how t=
o get
> > > > > things
> > > > > >> > >> > > running by
> > > > > >> > >> > > looking through the express codebase (though it wasn'=
t
> > > > > impossible
> > > > > >> > >> > > ;)).
>
> > > > > >> > >> > > I hope I can publish some code examples rather sooner=
 than
> > > > > later
> > > > > >> > >> > > (maybe by the end of the next week).
>
> > > > > >> > >> > > =A0 Best regards,
> > > > > >> > >> > > =A0 Dennis
>
> > > > > >> > >> > > Am 07.07.2010 um 14:53 schrieb Aaron Heckmann:
>
> > > > > >> > >> > > > There isn't more documentation :( , just the code i=
tself
> > > > > which
> > > > > >> > >> > > > is
> > > > > >> > >> > > > documented well. The project also contains specs an=
d
> > > examples
> > > > > >> > >> > > > between
> > > > > >> > >> > > > which should provide a big help too.
>
> > > > > >> > >> > > > On 7/7/10, Sammaye <sam.mill...@gmail.com> wrote:
> > > > > >> > >> > > >> Ah yes I understand now.
>
> > > > > >> > >> > > >> I was worried about duplicate urls originally but =
after
> > > > > >> > >> > > >> reading
> > > > > >> > >> > > >> that
> > > > > >> > >> > > >> page it seems as though I've got more options than=
 I
> > > > > >> > >> > > >> originally
> > > > > >> > >> > > >> thought with URLs :)
>
> > > > > >> > >> > > >> Basically I am used to defining seperate functions=
 in
> > > i.e.
> > > > > >> > >> > > >> server
> > > > > >> > >> > > >> side
> > > > > >> > >> > > >> with normal url paths decoded from url rewrites (s=
o
> > > /post/1
> > > > > >> > >> > > >> becomes
> > > > > >> > >> > > >> post.php?id=3D1) and I was worried about trying to=
 decode
> > > my
> > > > > >> > >> > > >> urls so
> > > > > >> > >> > > >> I
> > > > > >> > >> > > >> didn't get ambiquity within my app but everything =
seems
> > > fine
> > > > > >> > >> > > >> after
> > > > > >> > >> > > >> ready that page now.
>
> > > > > >> > >> > > >> Do you know if theres a clear outline of all funct=
ions
> > > (api
> > > > > >> > >> > > >> documentation)? Both the wiki and the main website=
 do
> > > not
> > > > > >> > >> > > >> outline
> > > > > >> > >> > > >> every function though they do hold some very inter=
esting
> > > > > >> > >> > > >> information.
>
> > > > > >> > >> > > >> Thanks,
>
> > > > > >> > >> > > >> On Jul 7, 12:40 pm, Aaron Heckmann <
> > > > > aaron.heckm...@gmail.com>
> > > > > >> > >> > > >> wrote:
> > > > > >> > >> > > >>>http://wiki.github.com/visionmedia/express/routing
>
> > > > > >> > >> > > >>> <http://wiki.github.com/visionmedia/express/routi=
ng
> > > >Not
> > > > > sure
> > > > > >> > >> > > >>> I
> > > > > >> > >> > > >>> understand.
> > > > > >> > >> > > >>> What do you mean by " but how can I use proper ge=
ts
> > > > > >> > >> > > >>> within a url that I can uniquely identify?"
>
> > > > > >> > >> > > >>> On Wed, Jul 7, 2010 at 7:24 AM, Sammaye
> > > > > >> > >> > > >>> <sam.mill...@gmail.com>
> > > > > >> > >> > > >>> wrote:
> > > > > >> > >> > > >>>> Hi Everyone,
>
> > > > > >> > >> > > >>>> I'm an absolute noob to both node.js and express
> > > however
> > > > > >> > >> > > >>>> have
> > > > > >> > >> > > >>>> been
> > > > > >> > >> > > >>>> getting to crips and have formed a bit of a kool=
 app
> > > > > however
> > > > > >> > >> > > >>>> I do
> > > > > >> > >> > > >>>> have
> > > > > >> > >> > > >>>> one little problem.
>
> > > > > >> > >> > > >>>> I am not using my node.js server directly I am
> > > accessing
> > > > > it
> > > > > >> > >> > > >>>> through
> > > > > >> > >> > > >>>> JQuery on a Nginx server and I access it like so
>
> > > "129.129.129.393:8124/?username=3Dsam&someotherpoo=3Dthis".
>
> > > > > >> > >> > > >>>> It is with complicated urls like this that I sta=
rt to
> > > get
> > > > > a
> > > > > >> > >> > > >>>> problem. I
> > > > > >> > >> > > >>>> can do "/sam/this" but then I get problems with
> > > defineing
> > > > > >> > >> > > >>>> the url
> > > > > >> > >> > > >>>> within the code and how express gets the url.
>
> > > > > >> > >> > > >>>> My current understanding is:
>
> > > > > >> > >> > > >>>> get(/:user/:something,function()
>
> > > > > >> > >> > > >>>> would get me /sam/this out of the url but how ca=
n I
> > > use
> > > > > >> > >> > > >>>> proper
> > > > > >> > >> > > >>>> gets
> > > > > >> > >> > > >>>> within a url that I can uniquely identify?
>
> > > > > >> > >> > > >>>> I mean what happens if I have another url that n=
eeds
> > > to be
> > > > > >> > >> > > >>>> /post/this
> > > > > >> > >> > > >>>> and would have the same structure within the exp=
ress
> > > code
> > > > > as
> > > > > >> > >> > > >>>> the
> > > > > >> > >> > > >>>> /sam/
> > > > > >> > >> > > >>>> this url?
>
> > > > > >> > >> > > >>>> Really what im looking for is a way to put a top=
 level
> > > > > >> > >> > > >>>> router
>
> ...
>