{"id":28533378,"url":"https://github.com/maklonfr/rest-api-students-data-management","last_synced_at":"2026-04-26T08:38:19.865Z","repository":{"id":296828143,"uuid":"994625954","full_name":"MaklonFR/REST-API-Students-Data-Management","owner":"MaklonFR","description":"This Express.js-based REST API provides a secure and efficient system for managing student data with authentication. The API enables user registration, authentication, and comprehensive CRUD operations for student records while maintaining data security through JWT-based authentication.","archived":false,"fork":false,"pushed_at":"2025-06-02T08:42:06.000Z","size":8945,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-02T19:42:38.317Z","etag":null,"topics":["authorization","expressjs","rest-api","students","token"],"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/MaklonFR.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,"zenodo":null}},"created_at":"2025-06-02T08:24:32.000Z","updated_at":"2025-06-02T08:43:38.000Z","dependencies_parsed_at":"2025-06-02T19:42:42.157Z","dependency_job_id":"cb87a3fd-517e-4603-bf7b-5d71812856fa","html_url":"https://github.com/MaklonFR/REST-API-Students-Data-Management","commit_stats":null,"previous_names":["maklonfr/api-students-login-register-auth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MaklonFR/REST-API-Students-Data-Management","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaklonFR%2FREST-API-Students-Data-Management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaklonFR%2FREST-API-Students-Data-Management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaklonFR%2FREST-API-Students-Data-Management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaklonFR%2FREST-API-Students-Data-Management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaklonFR","download_url":"https://codeload.github.com/MaklonFR/REST-API-Students-Data-Management/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaklonFR%2FREST-API-Students-Data-Management/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264142572,"owners_count":23563522,"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":["authorization","expressjs","rest-api","students","token"],"created_at":"2025-06-09T17:06:49.208Z","updated_at":"2026-04-26T08:38:19.810Z","avatar_url":"https://github.com/MaklonFR.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Student Management API: Secure REST API for Student Data Management\n\nThis Express.js-based REST API provides a secure and efficient system for managing student data with authentication. The API enables user registration, authentication, and comprehensive CRUD operations for student records while maintaining data security through JWT-based authentication.\n\nThe system features robust user authentication with password hashing and JWT token generation, along with complete student management capabilities including creation, retrieval, updating, and deletion of student records. It implements input validation, error handling, and database persistence using MySQL, making it suitable for educational institutions requiring a secure student management system.\n\n## Repository Structure\n```\nstudent-api/\n├── config/                 # Configuration files directory\n│   ├── database.js        # MySQL database connection configuration\n│   └── schema.sql         # Database schema definitions\n├── middleware/\n│   └── auth.js            # JWT authentication middleware\n├── index.js               # Main application entry point with route definitions\n├── package.json           # Project dependencies and scripts\n└── test.js               # API endpoint tests using Jest and Supertest\n```\n\n## Usage Instructions\n### Prerequisites\n- Node.js (v14 or higher)\n- MySQL Server (v8.0 or higher)\n- npm (Node Package Manager)\n\nRequired environment variables:\n```\nPORT=3000\nJWT_SECRET=your_jwt_secret\nDB_HOST=localhost\nDB_USER=your_db_user\nDB_PASSWORD=your_db_password\nDB_NAME=your_database_name\n```\n\n### Installation\n\n1. Clone the repository:\n```bash\ngit clone \u003crepository-url\u003e\ncd student-api\n```\n\n2. Install dependencies:\n```bash\nnpm install\n```\n\n3. Set up the database:\n```bash\n# Log into MySQL\nmysql -u root -p\n\n# Create database and tables\nmysql\u003e source config/schema.sql\n```\n\n4. Create a `.env` file in the project root with the required environment variables.\n\n5. Start the server:\n```bash\n# Development mode\nnpm run dev\n\n# Production mode\nnpm start\n```\n\n### Quick Start\n\n1. Register a new user:\n```bash\ncurl -X POST http://localhost:3000/api/auth/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"username\": \"testuser\", \"email\": \"test@example.com\", \"password\": \"password123\"}'\n```\n\n2. Login to get JWT token:\n```bash\ncurl -X POST http://localhost:3000/api/auth/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"username\": \"testuser\", \"password\": \"password123\"}'\n```\n\n3. Create a new student (using JWT token):\n```bash\ncurl -X POST http://localhost:3000/api/students \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"John Doe\", \"studentId\": \"ST001\", \"email\": \"john.doe@example.com\"}'\n```\n\n### More Detailed Examples\n\n1. Get all students:\n```bash\ncurl -X GET http://localhost:3000/api/students \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\"\n```\n\n2. Get student by ID:\n```bash\ncurl -X GET http://localhost:3000/api/students/ST001 \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\"\n```\n\n3. Update student:\n```bash\ncurl -X PUT http://localhost:3000/api/students/ST001 \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"John Smith\", \"studentId\": \"ST001\", \"email\": \"john.smith@example.com\"}'\n```\n\n### Troubleshooting\n\nCommon Issues:\n\n1. Authentication Errors\n- Error: \"Authentication required\"\n  - Ensure JWT token is included in Authorization header\n  - Check token format: `Bearer \u003ctoken\u003e`\n  - Verify token has not expired\n\n2. Database Connection Issues\n- Error: \"Error connecting to database\"\n  - Verify MySQL server is running\n  - Check database credentials in .env file\n  - Ensure database and tables exist\n\n3. Validation Errors\n- Error: \"Student ID already exists\"\n  - Use unique student ID when creating/updating students\n- Error: \"Invalid email format\"\n  - Ensure email follows standard format (example@domain.com)\n\n## Data Flow\n\nThe API processes requests through authentication, validation, and database operations to manage student data securely.\n\n```ascii\nClient Request → JWT Auth → Input Validation → Database Operation → Response\n     ↑                                                                 |\n     |_________________________________________________________________|\n```\n\nKey Component Interactions:\n1. Client sends authenticated request with JWT token\n2. Auth middleware validates token and extracts user information\n3. Input validation middleware checks request payload\n4. Database operations execute through connection pool\n5. Response returns with appropriate status and data\n6. Error handling occurs at each step with appropriate responses\n\n## Result\n\n### Register Testing\n![image](https://github.com/user-attachments/assets/f61840b4-ba3f-45d1-8137-f42cea668436)\n\n### Login Testing\n![image](https://github.com/user-attachments/assets/cef33767-71ec-4282-b6cf-9770f197cba0)\n\n### GET-Students Testing\n![image](https://github.com/user-attachments/assets/29aa2ff2-5a95-41c2-a2c4-2d139108621b)\n\n### POST-Student Testing\n![image](https://github.com/user-attachments/assets/6550dd29-9d8d-42c1-87ae-76d075348cad)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaklonfr%2Frest-api-students-data-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaklonfr%2Frest-api-students-data-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaklonfr%2Frest-api-students-data-management/lists"}