{"id":29440017,"url":"https://github.com/fakhrezy/restfull-api-js","last_synced_at":"2026-05-15T20:05:49.504Z","repository":{"id":303965149,"uuid":"1017326952","full_name":"Fakhrezy/restfull-api-js","owner":"Fakhrezy","description":"restfull api backend with javascript ","archived":false,"fork":false,"pushed_at":"2025-07-10T11:21:31.000Z","size":6307,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-23T13:18:45.606Z","etag":null,"topics":["api","javascript","nosql","postman","restful-api","sql"],"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/Fakhrezy.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-07-10T11:12:57.000Z","updated_at":"2025-07-10T11:22:33.000Z","dependencies_parsed_at":"2025-07-10T19:09:23.419Z","dependency_job_id":null,"html_url":"https://github.com/Fakhrezy/restfull-api-js","commit_stats":null,"previous_names":["fakhrezy/restfull-api-js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Fakhrezy/restfull-api-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fakhrezy%2Frestfull-api-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fakhrezy%2Frestfull-api-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fakhrezy%2Frestfull-api-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fakhrezy%2Frestfull-api-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fakhrezy","download_url":"https://codeload.github.com/Fakhrezy/restfull-api-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fakhrezy%2Frestfull-api-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33078044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:05:40.333Z","status":"ssl_error","status_checked_at":"2026-05-15T20:05:38.672Z","response_time":103,"last_error":"SSL_read: 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":["api","javascript","nosql","postman","restful-api","sql"],"created_at":"2025-07-13T10:01:53.287Z","updated_at":"2026-05-15T20:05:49.480Z","avatar_url":"https://github.com/Fakhrezy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REST API Project - User Management\n\nProyek REST API sederhana untuk manajemen user dengan dukungan MySQL dan MongoDB menggunakan Node.js dan Express.js.\n\n## Instalasi\n\n1. Clone repository ini\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Pastikan MySQL dan MongoDB sudah terinstall dan berjalan di sistem Anda\n\n4. Konfigurasi koneksi database di folder `config/`:\n   - `mysqlConfig.js` - untuk konfigurasi MySQL\n   - `mongoConfig.js` - untuk konfigurasi MongoDB\n\n## ▶ Menjalankan Server\n\n```bash\nnode rest-api/server.js\n```\n\nServer akan berjalan di `http://localhost:3000`\n\n## 🛠 API Endpoints\n\n### MySQL Endpoints\n\n- `GET /api/users/mysql-show` - Ambil semua user dari MySQL\n- `POST /api/users/mysql-add` - Tambah user baru ke MySQL\n- `PUT /api/users/mysql-edit/:id` - Update user di MySQL\n- `DELETE /api/users/mysql-delete/:id` - Hapus user dari MySQL\n\n### MongoDB Endpoints\n\n- `GET /api/users/mongo-show` - Ambil semua user dari MongoDB\n- `POST /api/users/mongo-add` - Tambah user baru ke MongoDB\n- `PUT /api/users/mongo-edit/:id` - Update user di MongoDB\n- `DELETE /api/users/mongo-delete/:id` - Hapus user dari MongoDB\n\n## Testing dengan Postman\n\n### 1. GET - Mengambil Semua User\n\n#### MySQL\n\n```\nMethod: GET\nURL: http://localhost:3000/api/users/mysql-show\nHeaders:\n  Content-Type: application/json\n```\n\n**contoh response:**\n\n```json\n[\n\t{\n\t\t\"id\": 1,\n\t\t\"name\": \"nama\",\n\t\t\"email\": \"email@mail.com\",\n\t\t\"age\": 25,\n\t\t\"createdAt\": \"2024-01-01T00:00:00.000Z\",\n\t\t\"updatedAt\": \"2024-01-01T00:00:00.000Z\"\n\t}\n]\n```\n\n#### MongoDB\n\n```\nMethod: GET\nURL: http://localhost:3000/api/users/mongo-show\nHeaders:\n  Content-Type: application/json\n```\n\n**Response:**\n\n```json\n[\n\t{\n\t\t\"_id\": \"60d0fe4f5311236168a109ca\",\n\t\t\"name\": \"nama\",\n\t\t\"email\": \"email@mail.com\",\n\t\t\"age\": 28,\n\t\t\"__v\": 0\n\t}\n]\n```\n\n### 2. POST - Menambah User Baru\n\n#### MySQL\n\n```\nMethod: POST\nURL: http://localhost:3000/api/users/mysql-add\nHeaders:\n  Content-Type: application/json\n```\n\n**Body (raw JSON):**\n\n```json\n{\n\t\"name\": \"name\",\n\t\"email\": \"email@mail.com\",\n\t\"age\": 30\n}\n```\n\n\n\n#### MongoDB\n\n```\nMethod: POST\nURL: http://localhost:3000/api/users/mongo-add\nHeaders:\n  Content-Type: application/json\n```\n\n**Body (raw JSON):**\n\n```json\n{\n\t\"name\": \"nama\",\n\t\"email\": \"email@mail.com\",\n\t\"age\": 32\n}\n```\n\n### 3. PUT - Update User\n\n#### MySQL\n\n```\nMethod: PUT\nURL: http://localhost:3000/api/users/mysql-edit/1\nHeaders:\n  Content-Type: application/json\n```\n\n**Body (raw JSON):**\n\n```json\n{\n\t\"name\": \"nama Updated\",\n\t\"email\": \"email.updated@mail.com\",\n\t\"age\": 26\n}\n```\n\n\n#### MongoDB\n\n```\nMethod: PUT\nURL: http://localhost:3000/api/users/mongo-edit/60d0fe4f5311236168a109ca\nHeaders:\n  Content-Type: application/json\n```\n\n**Body (raw JSON):**\n\n```json\n{\n\t\"name\": \"nama Updated\",\n\t\"email\": \"email.updated@mail.com\",\n\t\"age\": 29\n}\n```\n\n### 4. DELETE - Hapus User\n\n#### MySQL\n\n```\nMethod: DELETE\nURL: http://localhost:3000/api/users/mysql-delete/1\nHeaders:\n  Content-Type: application/json\n```\n\n**Response:**\n\n```json\n{\n\t\"message\": \"User deleted successfully\"\n}\n```\n\n#### MongoDB\n\n```\nMethod: DELETE\nURL: http://localhost:3000/api/users/mongo-delete/60d0fe4f5311236168a109ca\nHeaders:\n  Content-Type: application/json\n```\n\n**Response:**\n\n```json\n{\n\t\"message\": \"User deleted successfully\"\n}\n```\n\n## Struktur Database\n\n### MySQL Table (users)\n\n```sql\nCREATE TABLE users (\n  id INT AUTO_INCREMENT PRIMARY KEY,\n  name VARCHAR(255) NOT NULL,\n  email VARCHAR(255) UNIQUE NOT NULL,\n  age INT NOT NULL,\n  createdAt DATETIME,\n  updatedAt DATETIME\n);\n```\n\n### MongoDB Collection (users)\n\n```javascript\n{\n  _id: ObjectId,\n  name: String (required),\n  email: String (required, unique),\n  age: Number (required),\n  __v: Number\n}\n```\n\n## Catatan\n\n1. **Port Default**: Server berjalan di port 3000\n2. **Content-Type**: Selalu gunakan `application/json` untuk header\n3. **ID Format**:\n   - MySQL menggunakan ID numerik (1, 2, 3, ...)\n   - MongoDB menggunakan ObjectId (24 karakter hex)\n4. **Error Handling**: API akan mengembalikan status code yang sesuai:\n   - 200: Success\n   - 201: Created\n   - 404: Not Found\n   - 500: Internal Server Error\n\n## 🔧 Collection Postman\n\nUntuk memudahkan testing, bisa membuat collection di Postman dengan struktur folder:\n\n```\nREST API - User Management\n├── MySQL\n│   ├── GET All Users (MySQL)\n│   ├── POST Add User (MySQL)\n│   ├── PUT Update User (MySQL)\n│   └── DELETE User (MySQL)\n└── MongoDB\n    ├── GET All Users (MongoDB)\n    ├── POST Add User (MongoDB)\n    ├── PUT Update User (MongoDB)\n    └── DELETE User (MongoDB)\n```\n\nPastikan untuk menyimpan environment variable di Postman:\n\n- `base_url`: `http://localhost:3000`\n\nSehingga URL bisa ditulis sebagai: `{{base_url}}/api/users/mysql-show`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffakhrezy%2Frestfull-api-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffakhrezy%2Frestfull-api-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffakhrezy%2Frestfull-api-js/lists"}