>
KeepCoding Projects - Web 18: 📁 repos-kc-web-18.md
>
Select your Language: Spanish 🔄 German
In order to practice and demonstrate the knowledge acquired in virtual classes, this project consists of developing an SSR (EJS) application for a second-hand items marketplace called Nodepop. The service maintains products for sale and allows searching with filters by various criteria.
- Node.js: event-driven model, V8 engine, version management with nvm/nvs, and package management with NPM/NPX.
- Advanced JavaScript: hoisting, scope (
var
/let
/const
), prototypes and classes, callbacks, asynchronicity with promises andasync/await
. - Event Loop and EventEmitter in Node.js for event handling.
- Modularization with CommonJS (
require
/module.exports
) and ES Modules (import
/export
). - MVC Architecture with Express and EJS templates; usage of Express Generator.
- Express.js: REST routes (
GET
,POST
,PUT
,DELETE
), parameters (req.params
,req.query
,req.body
), middlewares (cookie-parser, express-validator), error handling and responses (res.json
,res.render
, etc.). - SQL Databases (MySQL/MariaDB) with
mysql2/promise
and Docker; basic CRUD queries. - ORMs: usage and comparison of Sequelize, TypeORM, Prisma, and Mikro-ORM.
- MongoDB (official driver): advanced CRUD operations (operators, geospatial queries, transactions); Mongoose as an ODM to define schemas, validations, methods, pagination, and geospatial indexes.
- Authentication: Basic HTTP Auth and session/cookie-based authentication (cookie anatomy and session storage).
- Password Security: using bcrypt, scrypt, and argon2 (instead of PBKDF2).
- Development Tools: Docker for reproducible environments, nodemon and cross-env for automatic reload and environment variables in development.
- Each post shows an image (or placeholder), name, description, price, and buy/sell indicator.
- Retrieved via
GET /api/v1/adverts
with optional filters:name=
,sale=
,price=
,tags=
,skip=
,limit=
,sort=
. - UI states: Empty (no posts), Loading, Error, Success (display list).
- Each post is clickable and leads to
/posts/:id
. - If the user is logged in (token present), a “Create Post” button appears →
/posts/new
.
- Displays an image (or placeholder), name, description, price, buy/sell status, tags, and owner.
- Retrieved via
GET /api/v1/adverts/:id
Returns 404 if not found. - UI states: Empty (404), Loading, Error, Success (display details).
- If the authenticated user is the owner, a “Delete” button appears →
DELETE /api/v1/adverts/:id
with confirmation.
- Accessible only if logged in; otherwise redirects to
/posts
with a notice. - Form fields: Photo (optional), Name*, Description*, Price*, Buy/Sell*, Tags*.
- On submit:
POST /api/v1/adverts
(headerAuthorization: Bearer <token>
), body asmultipart/form-data
or JSON. - UI states: Loading, Error (validation or server), Success (redirect to
/posts/:id
).
- Form fields: Email*, Password*, (Remember session).
POST /api/auth/login
payload{ "email": "user@example.com", "password": "********" }
.- UI states: Loading, Error (invalid credentials), Success (save token and redirect to
/posts
).
- Similar to login, with Email*, Password*, Confirm Password*.
POST /api/auth/signup
payload{ "email": "new@example.com", "password": "********" }
.- UI states: Loading, Error (email taken or validation), Success (save token and redirect or go to login).
- Pagination in listing:
?limit=10&skip=<offset>
, “Previous”/“Next” buttons. - Dynamic search: input with debounce querying
GET /api/v1/adverts?name=
. - Post editing (owner only): prefilled form at
/posts/:id/edit
,
PUT /api/v1/adverts/:id
. - Filtering by static tags: checkboxes or dropdown with tags (
work
,lifestyle
,motor
,mobile
). - Dynamic tags: get list from
GET /api/v1/adverts/tags
and build frontend filter.
- The
initDB.js
script must include sample users and products for testing. - For filters, build a
filters
object based on received parameters and pass it to
Product.find(filters)
along with pagination and sorting options. - When sending arrays (for example,
tags
), ensure to use JSON in the request body.
- Languages: EJS, CSS, JavaScript.
- Notable Dependencies (Node.js): express, eslint, nodemon, mongoose, morgan, and multer.
- Node.js (tested on version v22.15.1)
- Git (tested on version 2.47.1.windows.1)
- Visual Studio Code (tested on version 1.99.0)
- MongoDB (tested on version 8.0.5)
- NoSQLBooster for MongoDB (tested on version 9.1.5)
- Live Server (VS Code extension, optional)
git clone https://github.com/pablo-sch/keepcoding-04-node-backend.git
>
View Cloning Demo in VSCode: 🎥 Gif Demo
Note: Make sure MongoDB is running on your local machine.
Then, follow these steps:
# Install project dependencies.
npm install
# Initialize the database (only required on first deployment).
npm run initDB
# Run the project in development mode.
npm run dev
npx nodemon .\bin\www
>
Project Preview: 👀 Preview
Project licensed under the MIT License. Free to use and distribute with attribution. External contributions are not accepted, but suggestions are welcome.