{"id":21681868,"url":"https://github.com/ronnmabunga/expressjs-fs-monolithic-user-api-demo","last_synced_at":"2026-05-10T19:55:41.749Z","repository":{"id":259379252,"uuid":"874907761","full_name":"ronnmabunga/expressjs-fs-monolithic-user-api-demo","owner":"ronnmabunga","description":"A code demonstration of a Monolithic API application built with Express.js, where users can register, authenticate, and verify authorization levels.","archived":false,"fork":false,"pushed_at":"2024-10-24T14:38:07.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-25T00:27:49.934Z","etag":null,"topics":["bcrypt","expressjs","fs","jsonwebtoken","monolithic-architecture","rest-api","swagger-ui"],"latest_commit_sha":null,"homepage":"https://simple-monolithic-user-api-demo.onrender.com/api-docs/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ronnmabunga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-10-18T17:22:50.000Z","updated_at":"2024-10-24T15:37:19.000Z","dependencies_parsed_at":"2024-10-25T00:41:41.829Z","dependency_job_id":"aaedccb2-c323-487f-ac4e-b24ca9b4dfc4","html_url":"https://github.com/ronnmabunga/expressjs-fs-monolithic-user-api-demo","commit_stats":null,"previous_names":["ronnmabunga/simple-monolithic-user-api-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ronnmabunga/expressjs-fs-monolithic-user-api-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ronnmabunga","download_url":"https://codeload.github.com/ronnmabunga/expressjs-fs-monolithic-user-api-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32869721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"ssl_error","status_checked_at":"2026-05-10T13:40:02.145Z","response_time":54,"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":["bcrypt","expressjs","fs","jsonwebtoken","monolithic-architecture","rest-api","swagger-ui"],"created_at":"2024-11-25T15:32:04.645Z","updated_at":"2026-05-10T19:55:41.729Z","avatar_url":"https://github.com/ronnmabunga.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monolithic Express.js User Authentication and Authorization API\n\n## Description\n\nThis is a code demonstration of a Monolithic API application built with Express.js, where users can register, authenticate, and verify authorization levels. It includes Swagger API documentation for easy route exploration.\n\nThe Swagger UI documentation can be viewed and tested at: \u003chttps://ronnmabunga-demo-apis.onrender.com/demo-api-2/api-docs/\u003e.\n\n## Features\n\n-   **Swagger API Documentation:** Provides documentation for each route directly accessible via the browser.\n-   **Monolithic Code Structure:**\n    -   All routes and server logic are defined in a single file (no separate route files or models).\n    -   Uses core packages such as cors, dotenv, and express.\n-   **User Data Handling:**\n    -   User data is stored in a local file (managed using the fs module).\n    -   No classes or models are used to define the data format.\n-   **Registration and Authentication:**\n    -   User passwords are encrypted using bcrypt before storing them.\n    -   JWT (JSON Web Tokens) are generated upon login, provided as Bearer Tokens for subsequent requests.\n-   **Authorization Middleware:**\n    -   Demonstrates varied responses depending on the user role; different responses if user is, either: an unauthenticated user, an authenticated non-admin user, or an authenticated admin user.\n\n## Sample Registered Credentials\n\nUse these sample users to test the API:\n\n-   **Admin User:**\n    ```json\n    { \"username\": \"admin\", \"password\": \"p@55w0rD\" }\n    ```\n-   **Non-admin User:**\n    ```json\n    { \"username\": \"U_ser-nam.e\", \"password\": \"p@55w0rD\" }\n    ```\n\n# How to Run\n\n1.  **Clone the Repository:**\n\n    ```bash\n    git clone https://github.com/ronnmabunga/expressjs-fs-monolithic-user-api-demo.git\n    cd expressjs-fs-monolithic-user-api-demo\n    ```\n\n2.  Install Dependencies:\n\n    ```bash\n    npm install\n    ```\n\n3.  Create a `.env` File:\n    Define the environment variables (like the JWT secret) in the .env file. Example:\n\n    ```env\n    JWT_SECRET=your_jwt_secret\n    PORT=your_port_number\n    ```\n\n4.  Run the Server:\n\n    ```bash\n    node index.js\n    ```\n\n5.  Access Swagger Documentation:\n\n-   Visit `http://localhost:{PORT}/api-docs` in your browser to explore the API routes with Swagger UI.\n    -   PORT - Port number indicated in the environment variables.\n\n## API Routes Overview\n\n-   **POST /users/register:** Registers a new user.\n-   **POST /users/login:** Authenticates a user and returns a JWT token.\n-   **GET /users/admin:** Restricted to authenticated admin users.\n-   **GET /users/non-admin:** Restricted to authenticated non-admin users.\n-   **GET /users/visitors:** Restricted to unauthenticated users.\n\n## Dependencies\n\n    express: Web framework for Node.js\n    cors: Enables Cross-Origin Resource Sharing\n    dotenv: Loads environment variables from .env\n    fs: File system module to handle data storage\n    bcrypt: Encrypts user passwords\n    jsonwebtoken: Generates and verifies JWT tokens\n    swagger-jsdoc: Generates Swagger documentation from JSDoc comments\n    swagger-ui-express: Serves Swagger documentation via a web interface\n\n# License\n\n    This project is licensed under the GNU GENERAL PUBLIC LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronnmabunga%2Fexpressjs-fs-monolithic-user-api-demo/lists"}