Hello Fellow-Node'rs :)

I'm building an ecommerce-type-ticketing website (like where users can buy 
tickets for broadway shoes, sports, etc.) using all Nodejs+Express+Jade 
combo. Nothing else - JS all the way...

So, here's my code structure...

+Tickets(root folder)
----> node_modules
----> public
-----------> css
-----------> font
-----------> img
-----------> js
----> server
-----------> config
-----------> lib
--------------------> dataaccess.js
--------------------> bizlogic.js
-----------> routes
--------------------> router.js
-----------> ssl
-----------> views
--------------------> index.jade
--------------------> ...jade (all other jade files)
-----> app.js
-----> package.json

So, here's the structure of my website.
The main home (index) has all the featured events, and other events with 
ticket prices, # of tickets, etc. (all event-related information) rendered 
on the main home page. and also in the header, a way for users to login via 
facebook, twitter or email-address-way...
I know how to take care of the login etc. issue...

So, here's my main home page (/) route - in the router.js file:

    app.get('/', function(req,res){
        // check if the user's credentials are saved in a cookie //
        if (req.cookies.user == undefined || req.cookies.pass == undefined){
            res.render('index');
        }
        else {
            res.render('index', {username: req.cookies.user});
        }
    });

However, how do I dynamically render data on the home/main/index page such 
as different list of events.
I have bunch of methods defined in bizlogic and dataaccess such as 
getEvents, listEvents and so on (that returns all the information about the 
events).
However, how do I render (wire up) this data also on the main home page. 
What do I need to do to my app.get('/') or app.get ('index') route? If I 
specify a route like app.get(/events) - that would probably render on 
<www.example.com/events> but I want events also to show up on index page /.

Is there another way that I should be structuring this or implementing my 
ticketing website?

One way I am thinking I can do this is implement some logic in the app.get 
route before I render index like so:
    app.get('/', function(req,res){
        // check if the user's credentials are saved in a cookie //
        if (req.cookies.user == undefined || req.cookies.pass == undefined){
            eventArray = getAllEvents(list, fn);
               ....callback logic...
              if (!events){
                  res.render('index');
               }
               else  {
                  res.render('index', {event 1 data, event 2 data, event 3 
data...});
                }
        }
        else {
            res.render('index', {username: req.cookies.user});
        }
    });
But this looks like a bad way to code this - no? There must be a better way 
to handle dynamic home pages with lot of content in node.

Any help appreciated...

Thanks,
JP


-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to