{"id":14967669,"url":"https://github.com/chaudinh/mo-cart","last_synced_at":"2026-01-25T01:03:13.881Z","repository":{"id":101992834,"uuid":"169537593","full_name":"ChauDinh/mo-cart","owner":"ChauDinh","description":"An E-commerce design convert from PSD to HTML and more.","archived":false,"fork":false,"pushed_at":"2019-02-28T10:11:50.000Z","size":79832,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T01:26:02.574Z","etag":null,"topics":["bootstrap4","css","expressjs","git","github-pages","lowdb","mvc","nodejs","nodejs-server","psd-to-html","pugjs","shortid"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChauDinh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-07T08:00:49.000Z","updated_at":"2023-07-11T03:42:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"27e62197-f957-4a9c-abd2-eb6c30ba6d51","html_url":"https://github.com/ChauDinh/mo-cart","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChauDinh%2Fmo-cart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChauDinh%2Fmo-cart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChauDinh%2Fmo-cart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChauDinh%2Fmo-cart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChauDinh","download_url":"https://codeload.github.com/ChauDinh/mo-cart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239242797,"owners_count":19606099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap4","css","expressjs","git","github-pages","lowdb","mvc","nodejs","nodejs-server","psd-to-html","pugjs","shortid"],"created_at":"2024-09-24T13:38:26.122Z","updated_at":"2025-11-01T01:30:21.374Z","avatar_url":"https://github.com/ChauDinh.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS Web Server With ExpressJS - MO.Cart, an e-commerce site for shopping books\n\nConverting a mock e-commerce PSD design into HTML, CSS.\n\n### Structures, Planning\n\n* Use a mock E-commerce Photoshop design\n* Use Bootstrap to make the responsive of the site\n* Use Bootstrap Carousel\n* Use NodeJS for the server\n\n\u003chr\u003e\n\n### Static Web Server \u0026 Dynamic Web Server\n\n#### Static web server\n\n* Easy to build\n* Cheap to host (HTML, CSS)\n* Fixed content\n\n#### Dynamic web server\n\n* Little hard to build\n* Costly than static server host\n* Easily edit content by their own\n\n#### Frameworks for dynamic web server \n\n* PHP: Laravel, Symfony, CakePHP, etc.\n* Java: Spring, Play Framework, etc.\n* Python: Django, Flask, etc.\n* Ruby: Rails\n* JavaScript: ExpressJS, SailsJS, MeteorJS, KoaJS, etc.\n\n\u003chr\u003e\n\n### Single Page Application (SPA) and Multipages Application\n\n#### Single Page Application\n\n* Content rendered in the front-end\n* No page reloading\n* Interact with data via some JSON API\n\n\n#### Multipages Application\n\n* Receive a request from client and response a HTML\n* Use page reloading\n\n\u003chr\u003e\n\n### Creating form to search data\n\n* Use form action\n* Use GET method\n\nCreate a search form (pug)\n```pug\nform(action=\"/users/search\", method=\"GET\")\n input(type=\"text\", name=\"q\")\n button Search\n```\nThen add logic for searching the typed text\n```js\napp.get(\"/users/search\", (req, res) =\u003e {\n let q = req.query.q;\n let matchedUsers = users.filter(user =\u003e {\n  return user.name.toLowerCase().indexOf(q.toLowerCase()) !== -1;\n })\n \n res.render('users/index', {\n  users: matchedUsers\n })\n});\n```\n\u003chr\u003e\n\n### Creating form to add data\n\n* Use form action\n* Use POST method\n* Use req.body\n\nCreate a form \n```pug\nform(action=\"/users/create\", method=\"POST\")\n label Name\n input(type=\"text\", name=\"name\")\n button Create\n```\n\nThen use body-parser middleware to retreive POST query parameters\n##### Installation\n```\nnpm install body-parser --save\n```\n##### Write middleware\n```js\nconst bodyParser = require(\"body-parser\");\n...\napp.use(bodyParser.json());\napp.use(bodyParser.urlencoded({ extended: true }));\n...\napp.post(\"/users/create\", (req, res) =\u003e {\n users.push(req.body);\n res.redirect(\"/users\");\n});\n```\n\u003chr\u003e \n\n### Use lowdb to store data\n\n##### Installation\n```\nnpm install lowdb --save\n```\n\n##### Set defaults\n```js\nconst low = require(\"lowdb\");\nconst FileSync = require(\"lowdb/adapters/FileSync\");\nconst adapter = new FileSync(\"db.json\");\nconst db = low(adapter);\n\ndb.defaults({ users: [], products: [] }).wriet();\n```\n\n##### Add to database\n```js\n...\napp.post(\"users/create\", (req, res) =\u003e {\n db.get(\"users\").push(req.body).write();\n res.redirect(\"/users\");\n});\n```\n\n##### Search database\n```js\napp.get(\"users/search\", (req, res) =\u003e {\n let q = req.query.q;\n let users = db.get(\"users\").value();\n let matchedUsers = users.filter(user =\u003e {\n  return user.name.toLowerCase().indexOf(q.toLowerCase()) !== -1;\n });\n \n res.render('users/index', {\n  users: matchedUsers\n });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaudinh%2Fmo-cart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaudinh%2Fmo-cart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaudinh%2Fmo-cart/lists"}