{"id":22969132,"url":"https://github.com/boolfalse/men-assessment","last_synced_at":"2026-04-05T20:32:09.699Z","repository":{"id":267500870,"uuid":"901400983","full_name":"boolfalse/men-assessment","owner":"boolfalse","description":"MongoDB + Express.js + Node.js assessment project","archived":false,"fork":false,"pushed_at":"2024-12-20T11:15:32.000Z","size":270,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T05:29:43.986Z","etag":null,"topics":["express","mongodb","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/boolfalse.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":"2024-12-10T15:35:20.000Z","updated_at":"2024-12-20T11:15:36.000Z","dependencies_parsed_at":"2025-04-02T05:37:13.610Z","dependency_job_id":null,"html_url":"https://github.com/boolfalse/men-assessment","commit_stats":null,"previous_names":["boolfalse/men-assessment"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/boolfalse/men-assessment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fmen-assessment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fmen-assessment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fmen-assessment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fmen-assessment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boolfalse","download_url":"https://codeload.github.com/boolfalse/men-assessment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fmen-assessment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31449332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T15:22:31.103Z","status":"ssl_error","status_checked_at":"2026-04-05T15:22:00.205Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["express","mongodb","nodejs"],"created_at":"2024-12-14T21:32:33.415Z","updated_at":"2026-04-05T20:32:09.663Z","avatar_url":"https://github.com/boolfalse.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## MEN stack assessment\n\n\n\n\n### About:\n\nMongoDB + Express.js + Node.js assessment project.\n\n\n\n\n### Table of Contents\n\n- [Features:](#features)\n- [Resources](#resources)\n- [Installation Steps](#installation_steps)\n- [List of Commands](#list_of_commands)\n- [Run with Docker](#run_with_docker)\n- [Run Tests with Docker](#run_tests_with_docker)\n- [Run Locally (without Docker)](#run_without_docker)\n- [Run Tests Locally (without Docker)](#run_tests_without_docker)\n- [Request Examples with `curl`](#curl_request_examples)\n  - [Root URL](#root_url)\n  - [Register as Referrer](#register_as_referrer)\n  - [Login (as regular user)](#login_as_regular_user)\n  - [User Profile](#user_profile)\n  - [Create Link (referral)](#create_link_referral)\n  - [Get Links (referrals)](#get_links_referrals)\n  - [Register a Referee](#register_a_referee)\n  - [Get Referral Data](#get_referral_data)\n  - [Login (as admin)](#login_as_admin)\n  - [Get Users (as admin)](#get_users_as_admin)\n- [Credentials for Manual Testing](#manual_testing_credentials)\n- [Author](#author)\n\n\n\n\n\u003ca name=\"features\"\u003e\u003c/a\u003e\n\n### Features:\n\n- User (referrer/referee) authentication via **JWT** and **password hashing**.\n- **Referral link creation** and registration of referees.\n- **Session/Cookie-based authentication** for admin.\n- Listing users with **pagination** and **search** functionality for admin.\n- Middlewares for authentication and **validation** (express-validator).\n- Containerized application with **Docker**.\n- Automated tests for regular users (non-admin) using: **Jest** (on [`master`](https://github.com/boolfalse/men-assessment/tree/master) branch).\n- Automated tests for regular users (non-admin) using: **Mocha**, **Chai**, **Supertest** (on [`tests_mocha`](https://github.com/boolfalse/men-assessment/tree/tests_mocha) branch).\n- API Documentation with **Postman**.\n- _More features can be added in the future._\n\n\n\n\n\u003ca name=\"resources\"\u003e\u003c/a\u003e\n\n### Resources:\n\n- API-endpoints overview on [Postman](https://documenter.getpostman.com/view/1747137/2sAYHwHPzM)\n\n\n- GitHub [Repository](https://github.com/boolfalse/men-assessment):\n```bash\ngit clone https://github.com/boolfalse/men-assessment.git \u0026\u0026 cd men-assessment\n```\n\n\n\n\n\u003ca name=\"installation_steps\"\u003e\u003c/a\u003e\n\n### Installation Steps:\n\n- Install dependencies:\n```bash\nnpm install\n```\n\n- Setup `.env` file as mentioned in `.env.example` file.\n\n\n- You can skip this if you're planning to run the application in a Docker container. Otherwise, create a database cluster on [MongoDB Atlas](https://cloud.mongodb.com/), get the connection string and set `MONGO_URI` variable in `.env` file as mentioned in `.env.example` file:\n```dotenv\n# Use this when connecting to MongoDB Atlas\nMONGO_URI=mongodb+srv://\u003cMONGO_USER\u003e:\u003cMONGO_PASS\u003e@\u003cMONGO_HOST\u003e/?retryWrites=true\u0026w=majority\n```\n\n\n\n\n\u003ca name=\"list_of_commands\"\u003e\u003c/a\u003e\n\n### List of Commands:\n\n\u003e **NOTE:** for detailed information, read the appropriate sections below.\n\nBelow is the list of commands available to run the application and tests.\n\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003eWork with Docker (click to expand/collapse)\u003c/strong\u003e\n  \u003c/summary\u003e\n\n- Before running with Docker, make sure to build the image:\n  ```bash\n  docker-compose build\n  ```\n\n- Run the application with Docker (short version without detached mode):\n  ```bash\n  docker-compose up\n  ```\n\n- Run the application with Docker (with seeding):\n  ```bash\n  DB_SEED=true docker-compose up\n  ```\n\n- Run unit tests with Docker:\n  ```bash\n  docker-compose run app npm run test:unit\n  ```\n\n- Run integration (end-to-end) tests with Docker:\n  ```bash\n  docker-compose run app npm run test:e2e\n  ```\n\n- Run all tests (unit and integration) with Docker:\n  ```bash\n  docker-compose run app npm run test\n  ```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003eWork in local / host machine (click to expand/collapse)\u003c/strong\u003e\n  \u003c/summary\u003e\n\n- Run the application locally:\n  ```bash\n  npm run start\n  ```\n\n- Run the application locally (with seeding):\n  ```bash\n  npm run start db:seed\n  ```\n\n- Run unit tests locally:\n  ```bash\n  npm run test:unit\n  ```\n\n- Run integration (end-to-end) tests locally:\n  ```bash\n  npm run test:e2e\n  ```\n\n- Run all tests (unit and integration) locally:\n  ```bash\n  npm run test\n  ```\n\n\u003c/details\u003e\n\n\n\n\n\u003ca name=\"run_with_docker\"\u003e\u003c/a\u003e\n\n### Run with Docker:\n\n- Build the image:\n```bash\ndocker-compose build\n```\n\n- This will run the application on port 3000 by default. `DB_SEED=true` is for seeding an admin user in the database. Run the container (`-d` for detached mode):\n```bash\nDB_SEED=true docker-compose up -d\n```\n\n- If you want to run the application without seeding the database, just use without `DB_SEED` command:\n```bash\ndocker-compose up -d\n```\n\n- **Optional:** Use this command to run on a different port (3001 is in the example).\n```bash\nHOST_PORT=3001 docker-compose up -d\n```\n\n- **Optional:** Check the application (for default port 3000):\n```bash\ncurl http://localhost:3000/api\n```\n\n- For stopping the running containers in detached mode:\n```bash\n# stop them by using the service names\ndocker stop men_assessment_app men_assessment_mongo\n\n# or by identifying their container IDs and stopping them\ndocker ps\ndocker stop \u003capp_id\u003e \u003cmongo_id\u003e\n```\n\n\n\n\n\u003ca name=\"run_tests_with_docker\"\u003e\u003c/a\u003e\n\n### Run Tests with Docker:\n\n\u003e **NOTE:** At this time test are written for the regular users (non-admin) only as per the assessment requirements. However, you can test admin endpoints manually using Postman or cURL.\n\n- Before running tests with Docker, make sure you've built the image as it's mentioned in the [Run with Docker](#run_with_docker) section:\n```bash\ndocker-compose build\n```\n\nBelow commands will set `NODE_ENV=development` and run the tests.\n\n- Run unit tests within a Docker container from the host machine.\n```bash\ndocker-compose run app npm run test:unit\n```\n\n- Run integration (end-to-end) tests within a Docker container from the host machine.\n```bash\ndocker-compose run app npm run test:e2e\n```\n\n- Run all tests (unit and integration) within a Docker container from the host machine.\n  This command will run unit tests first and then integration (e2e) tests.\n```bash\ndocker-compose run app npm run test\n```\n\n\n\n\n\u003ca name=\"run_without_docker\"\u003e\u003c/a\u003e\n\n### Run Locally (without Docker):\n\n- Make sure you have the following installed on your system:\n  - Node.js (v18 or higher) with npm\n  - MongoDB (v4.4 or higher)\n  - Postman (for manual testing)\n  - cURL (for manual testing)\n\n\n- Run the application. `db:seed` is an optional command to seed admin user in the database.\n```bash\nnpm run start db:seed\n```\n\n- Run the application (development):\n```bash\nnpm run dev\n```\n\n\n\n\n\u003ca name=\"run_tests_without_docker\"\u003e\u003c/a\u003e\n\n### Run Tests Locally (without Docker):\n\n\u003e **NOTE:** At this time test are written for the regular users (non-admin) only as per the assessment requirements. However, you can test admin endpoints manually using Postman or cURL.\n\nBelow commands will set `NODE_ENV=development` and run the tests.\n\n- Run unit tests.\n```bash\nnpm run test:unit\n```\n\n- Run integration (end-to-end) tests within a Docker container from the host machine.\n```bash\nnpm run test:e2e\n```\n\n- Run all tests (unit and integration).\n  This command will run unit tests first and then integration (e2e) tests.\n```bash\nnpm run test\n```\n\n\n\n\n\u003ca name=\"curl_request_examples\"\u003e\u003c/a\u003e\n\n### Request Examples with `curl`:\n\nUse below `curl` commands in your CLI step-by-step to test the API endpoints manually.\n\n**NOTES**: Before running the commands, make sure to:\n- Check Postman documentation for the API-endpoints overview mentioned in the [Resources](#resources) section.\n- Modify `name`, `email`, `password`, and `referral_key` values as per your choice.\n- Replace `\u003cBEARER_TOKEN\u003e` with the actual token received from the login response.\n- Replace `1234abcd` with the actual referral key received from the **Create Link** response.\n- Replace URL port `3000` with the actual port if the application is running on a different port.\n\n\n\u003ca name=\"root_url\"\u003e\u003c/a\u003e\n\n#### Root URL\n\nTest the root URL:\n```bash\ncurl --location 'http://localhost:3000/api'\n```\n\n\n\u003ca name=\"register_as_referrer\"\u003e\u003c/a\u003e\n\n#### Register as Referrer\n\nRegister a new user (`referral_key` not provided):\n\n`name`: Referrer, `email`: referrer@example.com, `password`: password\n```bash\ncurl --location 'http://localhost:3000/api/users/register' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--data-urlencode 'name=Referrer' \\\n--data-urlencode 'email=referrer@example.com' \\\n--data-urlencode 'password=password' \\\n--data-urlencode 'referral_key='\n```\n\n\n\u003ca name=\"login_as_regular_user\"\u003e\u003c/a\u003e\n\n#### Login (as regular user)\n\nLogin as a regular user:\n\n`email`: referrer@example.com, `password`: password\n```bash\ncurl --location 'http://localhost:3000/api/users/login' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--data-urlencode 'email=referrer@example.com' \\\n--data-urlencode 'password=password'\n```\n\n\n\u003ca name=\"user_profile\"\u003e\u003c/a\u003e\n\n#### User Profile\n\nGet the profile of the authenticated user:\n\n`BEARER_TOKEN` is the token received from the login response.\n```bash\ncurl --location 'http://localhost:3000/api/users/profile' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--header 'Authorization: Bearer \u003cBEARER_TOKEN\u003e'\n```\n\n\n\u003ca name=\"create_link_referral\"\u003e\u003c/a\u003e\n\n#### Create Link (referral)\n\nCreate a referral link:\n\n`BEARER_TOKEN` is the token received from the login response.\n```bash\ncurl --location --request POST 'http://localhost:3000/api/links' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--header 'Authorization: Bearer \u003cBEARER_TOKEN\u003e'\n```\n\n\n\u003ca name=\"get_links_referrals\"\u003e\u003c/a\u003e\n\n#### Get Links (referrals)\n\nGet the referral links created by the referrer:\n\n`BEARER_TOKEN` is the token received from the login response.\n```bash\ncurl --location 'http://localhost:3000/api/links' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--header 'Authorization: Bearer \u003cBEARER_TOKEN\u003e'\n```\n\n\n\u003ca name=\"register_a_referee\"\u003e\u003c/a\u003e\n\n#### Register a Referee\n\nRegister a new user using the referral key (`referral_key` provided):\n\n`name`: Referee, `email`: referee@example.com, `password`: password, `referral_key`: 1234abcd, `BEARER_TOKEN` is the token received from the login response.\n```bash\ncurl --location 'http://localhost:3000/api/users/register' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--header 'Authorization: Bearer \u003cBEARER_TOKEN\u003e' \\\n--data-urlencode 'name=Referee' \\\n--data-urlencode 'email=referee@example.com' \\\n--data-urlencode 'password=password' \\\n--data-urlencode 'referral_key=1234abcd'\n```\n\n\n\u003ca name=\"get_referral_data\"\u003e\u003c/a\u003e\n\n#### Get Referral Data\n\nGet the count of referrals registered for a single link (referral):\n\n`BEARER_TOKEN` is the token received from the login response.\n```bash\ncurl --location 'http://localhost:3000/api/links/' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--header 'Authorization: Bearer \u003cBEARER_TOKEN\u003e'\n```\n\n\n\u003ca name=\"login_as_admin\"\u003e\u003c/a\u003e\n\n#### Login (as admin)\n\nLogin as an admin user:\n\n`email`: admin@example.com, `password`: password\n```bash\ncurl --location 'http://localhost:3000/api/admin/login' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--data-urlencode 'email=admin@example.com' \\\n--data-urlencode 'password=password'\n```\n\n\n\u003ca name=\"get_users_as_admin\"\u003e\u003c/a\u003e\n\n#### Get Users (as admin)\n\nGet users with pagination:\n`per` is the number of users per page and `page` is the page number. Maximum `per` value can be set to 10. Default `per` value is 5. Default `page` value is 1. `term` is the search term for filtering users by name or email. `term` is case-insensitive and can be 1-20 characters long.\n\n`BEARER_TOKEN` is the token received from the admin login response. `per`: 2, `page`: 1, `term`: ReFeR\n```bash\ncurl --location 'http://localhost:3000/api/admin/users?per=2\u0026page=1\u0026term=ReFeR' \\\n--header 'Cookie: admin_token=\u003cBEARER_TOKEN\u003e'\n```\n\n\n\n\n\u003ca name=\"manual_testing_credentials\"\u003e\u003c/a\u003e\n\n### Credentials for Manual Testing:\n\nBelow are admin user credentials for testing:\n```text\nemail: admin@example.com\npassword: password\n```\n\nBelow are regular user credentials for testing:\n```text\n# Referrer\nemail: referrer@example.com\npassword: password\n\n# Referee\nemail: referee@example.com\npassword: password\n```\n\n\n\n\n\u003ca name=\"author\"\u003e\u003c/a\u003e\n\n### Author:\n\n- [Website](https://boolfalse.com)\n- [LinkedIn](https://www.linkedin.com/in/boolfalse/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboolfalse%2Fmen-assessment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboolfalse%2Fmen-assessment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboolfalse%2Fmen-assessment/lists"}