{"id":20330235,"url":"https://github.com/sabo99/nodejs-restfulapi-jwt-sequelize-mysql","last_synced_at":"2026-04-14T06:01:59.873Z","repository":{"id":44644493,"uuid":"429326726","full_name":"sabo99/nodejs-restfulapi-jwt-sequelize-mysql","owner":"sabo99","description":"NodeJS-Express | Restful API with MySQL : User Authentication \u0026 Authentication JWT (Json Web Token)","archived":false,"fork":false,"pushed_at":"2022-03-28T04:22:07.000Z","size":161,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T15:20:24.058Z","etag":null,"topics":["expressjs","jsonwebtoken","mysql2","nodejs","restful-api","userauthentication"],"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/sabo99.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}},"created_at":"2021-11-18T06:53:07.000Z","updated_at":"2022-05-10T02:53:02.000Z","dependencies_parsed_at":"2022-09-13T17:40:27.741Z","dependency_job_id":null,"html_url":"https://github.com/sabo99/nodejs-restfulapi-jwt-sequelize-mysql","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/sabo99%2Fnodejs-restfulapi-jwt-sequelize-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabo99%2Fnodejs-restfulapi-jwt-sequelize-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabo99%2Fnodejs-restfulapi-jwt-sequelize-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabo99%2Fnodejs-restfulapi-jwt-sequelize-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sabo99","download_url":"https://codeload.github.com/sabo99/nodejs-restfulapi-jwt-sequelize-mysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241844982,"owners_count":20029754,"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":["expressjs","jsonwebtoken","mysql2","nodejs","restful-api","userauthentication"],"created_at":"2024-11-14T20:15:32.680Z","updated_at":"2026-04-14T06:01:54.847Z","avatar_url":"https://github.com/sabo99.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://nodejs.org/en/\"\u003e\n    \u003cimg src=\"https://img.icons8.com/color/128/000000/nodejs.png\" width=\"100\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e\n  Restful API with MySQL \u003cbr\u003e User Authentication + CRUD \u0026 Authentication JWT (Json Web Token)\n\u003c/h1\u003e\n\n## 🚀 Quick start\n\n1.  **Create a NodeJS app.**\n\n    Use the NodeJS CLI to create a new app, specifying the minimal starter.\n\n    ```shell\n    # create a new NodeJS site using the minimal starter\n    npm init --y\n    ```\n2. **Setting up automatically update server**\n    ```json\n    ...\n    \"scripts\": {\n        ...\n        \"start\": \"nodemon server.js\"\n    },\n    ```\n\n3.  **Start developing.**\n\n    Navigate into your new app directory and start it up.\n\n    ```shell\n    cd [folder_name]\n    npm start\n    ```\n\n4.  **Open the code and start customizing!**\n\n    Your server is now running at http://localhost:3000!\n\n    Edit `/server.js` to see your server update in real-time!\n\n\n## Technology Used\n\n-   `bcryptjs: ^2.4.3`\n-   `cors: ^2.8.5`\n-   `dotenv: ^10.0.0`\n-   `express: ^4.17.1`\n-   `joi: ^17.4.2`\n-   `jsonwebtoken: ^8.5.1`\n-   `mysql2: ^2.3.3`\n-   `nodemon: ^2.0.15`\n-   `sequelize: ^6.9.0`\n-   `sequelize-cli: ^6.3.0`\n\n\u003cbr\u003e\n\n## Project Structure\n\n\u003cimg src=\"./Project Structure.png\"\u003e\n\n\u003cbr\u003e\n\n## APIs Provided\n\n| Methods     | Urls             |           Actions           |   Token    |\n| :---------- | :--------------- | :-------------------------: | :--------: |\n| POST        | /api/auth/signup |     SignUp new Account      |     -      |\n| POST        | /api/auth/signin |      Login an Account       |     -      |\n| GET         | /api/user/list   | Retrieve Users List Content | `Required` |\n| GET         | /api/user/find   |    Retrieve User Content    | `Required` |\n| PUT / PATCH | /api/user/{id}   |     Update User Content     | `Required` |\n| DELETE      | /api/user/{id}   |     Delete User Content     | `Required` |\n\n\u003cbr\u003e\n\n## Flow for SignUp \u0026 SignIn with JWT Authentication\n\nFollowing diagram shows the flow that we will implement for the `User Registration`, `User Login`, and `Authenticate JWT` Processes.\n\n\u003cimg src=\"./Flow for Signup \u0026 Login with JWT Authentication.png\"\u003e\n\n\u003cbr\u003e\u003cbr\u003e\n\n## APIs Specification\n\n\u003ca href=\"https://www.getpostman.com/collections/1f14b750916ed2fefd28\"\u003e `https://www.getpostman.com/collections/1f14b750916ed2fefd28` \u003c/a\u003e\n\u003cbr\u003e\n\n## `User Registration`\n\nRequest :\n\n-   Method : `POST`\n-   Endpoint : `/api/auth/signup`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n\n     \u003cbr\u003e\n\n-   Body :\n\n    ```json\n    {\n        \"email\": \"string\",\n        \"username\": \"string\",\n        \"password\": \"string, hash\"\n    }\n    ```\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": {\n            \"id\": \"string\",\n            \"email\": \"string\",\n            \"username\": \"string\",\n            \"createdAt\": \"date-string\"\n        }\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `User Login`\n\nRequest :\n\n-   Method : `POST`\n-   Endpoint : `/api/auth/signin`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n\n     \u003cbr\u003e\n\n-   Body :\n    ```json\n    {\n        \"username\": \"string\",\n        \"password\": \"string, hash\"\n    }\n    ```\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": {\n            \"id\": \"string\",\n            \"email\": \"string\",\n            \"username\": \"string\",\n            \"createdAt\": \"date-string\"\n        }\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `User List`\n\n#### `Require token`\n\nRequest :\n\n-   Method : `GET`\n-   Endpoint : `/api/user/list`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": [\n            {\n                \"id\": \"string\",\n                \"email\": \"string\",\n                \"username\": \"string\",\n                \"createdAt\": \"date-string\"\n            },\n            {\n                \"id\": \"string\",\n                \"email\": \"string\",\n                \"username\": \"string\",\n                \"createdAt\": \"date-string\"\n            }\n        ]\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `Find User`\n\n#### `Require token`\n\n#### example: `/api/user/find?id=1`\n\nRequest :\n\n-   Method : `GET`\n-   Endpoint : `/api/user/find`\n-   Query :\n\n    -   id : `string`\n\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\",\n        \"user\": {\n            \"id\": \"string\",\n            \"email\": \"string\",\n            \"username\": \"string\",\n            \"createdAt\": \"date-string\"\n        }\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `Update User`\n\n#### `Require token`\n\nRequest :\n\n-   Method : `PUT / PATCH`\n-   Endpoint : `/api/user/{id}`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Body :\n\n    ```json\n    {\n        \"email\": \"string\",\n        \"username\": \"string\",\n        \"password\": \"string, hash\"\n    }\n    ```\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\"\n    }\n    ```\n\n    \u003cbr\u003e\n\n## `Delete User`\n\n#### `Require token`\n\nRequest :\n\n-   Method : `DELETE`\n-   Endpoint : `/api/user/{id}`\n-   Header :\n\n    -   Content-Type : `application/json`\n    -   Accept : `application/json`\n    -   x-auth-token : `string`\n\n    \u003cbr\u003e\n\n-   Response :\n\n    ```json\n    {\n        \"code\": \"number\",\n        \"message\": \"string\"\n    }\n    ```\n\n    \u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabo99%2Fnodejs-restfulapi-jwt-sequelize-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabo99%2Fnodejs-restfulapi-jwt-sequelize-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabo99%2Fnodejs-restfulapi-jwt-sequelize-mysql/lists"}