Special offer for new customers: 5% OFF your first order! Use coupon: GWRITERSclose

Node.js

Using Node.js, write a simple online store with whatever it is that youre interested in. The main page should display a list of products on offer with an option of adding each product to the shopping cart. From the main page the user can also decide to checkout and is then transferred to the checkout view which presents his/her shopping cart where each product can be removed from the cart. The whole purchase can be either cancelled (which simply clears the shopping cart) or finalized (which permanently removes the products from the list). In either case, the user is redirected to the main page and an appropriate message is displayed. If the purchase is unsuccessful (e.g., one of the products was bought by another user in the meantime), the user should be redirected back to the shopping cart page with an appropriate message. The shopping cart view also allows the user to simply go back to the main page.
The products should be stored in a database (e.g., MySQL, MongoDb). Heres a link that should help with that. A single table (e.g., products) with a single column (e.g., name) is sufficient, but you can obviously play around with it a bit more if you want to (id, image, description, quantity, etc.). When executing queries with parameters, make sure to use data binding rather than simply concatenating the parameters with the query string. If you dont know why, read this.
The users do not need to be identified in any other way than through session, so theres no need to write the register/login functionality. New session = new user. Session should also be used to store the shopping cart. Once a product is added to the cart it is not removed from the list other users can still see it and add to their carts. It is only after the purchase is finalized that the products are removed. Keep that in mind when testing your application! Watch out for cases when two users have some of the same items in their baskets and both want to finalize the purchase (critical section).
You can use a templating engine like EJS introduced in the presentation or one of many other compatible with express.
Remember to use the HTTP protocol correctly!  Test your website thoroughly to make sure everything works as it should: refresh the page after finalization and adding to cart, use the browsers back and forward buttons. Also, dont forget to use the POST REDIRECT GET pattern (redirecting in express is extremely easy simply call res.redirect instead of res.send and thats it)!
Potentially useful modules include: express, express-session, ejs, body-parser, mysql/mongodb.

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes