{"id":25683184,"url":"https://github.com/danilppzz/node-auth","last_synced_at":"2026-04-11T12:47:57.536Z","repository":{"id":244574219,"uuid":"815196370","full_name":"danilppzz/node-auth","owner":"danilppzz","description":"This project is a simple web application built with Express.js that includes user authentication and authorization using JSON Web Tokens (JWT). It uses EJS as the templating engine and manages cookies for session handling. It also includes a local database implementation using db-local for user data storage and bcrypt for password hashing.","archived":false,"fork":false,"pushed_at":"2024-06-18T22:31:44.000Z","size":6256,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-19T20:03:34.089Z","etag":null,"topics":["authentication","expressjs","nodejs"],"latest_commit_sha":null,"homepage":"http://localhost:3000/","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/danilppzz.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-06-14T15:01:45.000Z","updated_at":"2024-06-18T22:31:47.000Z","dependencies_parsed_at":"2024-06-15T19:04:11.165Z","dependency_job_id":null,"html_url":"https://github.com/danilppzz/node-auth","commit_stats":null,"previous_names":["danilppzz/node-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilppzz%2Fnode-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilppzz%2Fnode-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilppzz%2Fnode-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilppzz%2Fnode-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danilppzz","download_url":"https://codeload.github.com/danilppzz/node-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240516665,"owners_count":19814051,"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":["authentication","expressjs","nodejs"],"created_at":"2025-02-24T16:41:43.486Z","updated_at":"2026-04-11T12:47:52.491Z","avatar_url":"https://github.com/danilppzz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv class=\"logo\" align=\"center\"\u003e\n  \u003cimg width=\"25%\" src=\"https://static-00.iconduck.com/assets.00/node-js-icon-454x512-nztofx17.png\" alt=\"bloons-logo\"\u003e\n  \u003cbr\u003e\n\u003c/div\u003e\n\n## Description\n\nThis project is a simple web application built with Express.js that includes user authentication and authorization using JSON Web Tokens (JWT). It uses EJS as the templating engine and manages cookies for session handling. It also includes a local database implementation using `db-local` for user data storage and `bcrypt` for password hashing.\n\n## Features\n\n- User registration\n- User login\n- JWT-based authentication\n- Middleware for session handling\n- Cookie management\n- Protected routes\n\n## Installation\n\n1. **Clone the repository:**\n\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd \u003crepository-directory\u003e\n    ```\n\n2. **Install dependencies:**\n\n    ```bash\n    pnpm install\n    ```\n\n3. **Set up configuration:**\n\n    Create a `config.js` file in the root directory with the following content:\n\n    ```javascript\n    export const SECRET_JWT_KEY = \"your-secret-key\";\n    export const PORT = 3000;\n    export const SALT_ROUNDS = 10;\n    ```\n\n4. **Run the application:**\n\n    ```bash\n    pnpm run dev\n    ```\n\n## Usage\n\n### Endpoints\n\n- **GET /**: Renders the homepage. If the user is logged in, user details are passed to the view.\n- **POST /login**: Logs in a user and sets a JWT token in an HTTP-only cookie.\n- **POST /register**: Registers a new user.\n- **POST /logout**: Logs out the user by clearing the JWT cookie.\n- **GET /protected**: Accesses a protected route. If the user is not authenticated, it returns a 403 status.\n\n### Middleware\n\nThe middleware checks for a JWT token in the cookies. If the token is valid, it attaches the user data to the session.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanilppzz%2Fnode-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanilppzz%2Fnode-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanilppzz%2Fnode-auth/lists"}