{"id":18504194,"url":"https://github.com/beresindev/beresin-express-backend-app","last_synced_at":"2026-02-12T04:53:03.604Z","repository":{"id":260649529,"uuid":"881951430","full_name":"beresindev/beresin-express-backend-app","owner":"beresindev","description":"Backend of BeresIn","archived":false,"fork":false,"pushed_at":"2024-12-01T11:23:45.000Z","size":233,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T14:41:21.265Z","etag":null,"topics":["backend","express","knexjs","nodejs","postgres","rest-apis"],"latest_commit_sha":null,"homepage":"https://restapi.beresin.software/api/status","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beresindev.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-11-01T15:03:59.000Z","updated_at":"2024-12-02T14:14:38.000Z","dependencies_parsed_at":"2024-11-09T16:38:38.609Z","dependency_job_id":"d386353b-2278-43ff-86ca-3066bc1c2f08","html_url":"https://github.com/beresindev/beresin-express-backend-app","commit_stats":{"total_commits":119,"total_committers":2,"mean_commits":59.5,"dds":0.008403361344537785,"last_synced_commit":"1f3df2bc73bd07ee029b72f840bd29f5bffaafaa"},"previous_names":["beresindev/beresindev-beresin-express-backend-app","beresindev/beresin-express-backend-app"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beresindev%2Fberesin-express-backend-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beresindev%2Fberesin-express-backend-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beresindev%2Fberesin-express-backend-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beresindev%2Fberesin-express-backend-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beresindev","download_url":"https://codeload.github.com/beresindev/beresin-express-backend-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250231208,"owners_count":21396425,"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":["backend","express","knexjs","nodejs","postgres","rest-apis"],"created_at":"2024-11-06T14:03:27.916Z","updated_at":"2026-02-12T04:53:03.568Z","avatar_url":"https://github.com/beresindev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg\n      src=\"https://github.com/user-attachments/assets/b5d64eaf-c8c3-4c63-ab9d-625221f06fa4\"\n      alt=\"Hoppscotch\"\n      height=\"64\"\n    /\u003e\n\u003c/div\u003e\n# beresin-express-backend-app\n\n## Backend of BeresIn\n\nThis is an [Express.js](https://expressjs.com) project, written in [TypeScript](https://www.typescriptlang.org), with a [PostgreSQL](https://www.postgresql.org) database using [Knex.js](https://knexjs.org) for query building.\n\nThe project provides a backend for the BeresIn platform, featuring user authentication, admin and user services management, and category CRUD operations, with a focus on secure data handling and a well-structured API.\n## Authors\n\n- [@beresindev](https://github.com/beresindev)\n- [@teamberesin](https://github.com/teamberesin)\n\n### Meet Beresin Team\n\n**Product Owner:**\n- [Muhammad Farhan Mustafa](github.com/farhanmustafa15)\n\n**UI/UX Design:**\n- Danny Kurniawan\n- Azmi Nadhia Asyarifa\n\n**Fullstack Website:**\n- [Muhammad Daniel Krisna Halim Putra](https://github.com/bforbilly24)\n\n**Frontend Mobile:**\n- [Adam Ghazy Al Falah](https://github.com/Adam-Ghazy)\n- [Habibi Daffa Filzana Nurus Syahada](https://github.com/habibidaffaa)\n## Tech Stack\n\n- **Programming Language / Superset:** [Typescript](https://www.typescriptlang.org)\n- **Runtime Environment:** [Node.js](https://nodejs.org)\n- **Framework:** [Express](https://expressjs.com)\n- **Query Builder:** [Knex](https://knexjs.org)\n- **RDBMS:** [PostgreSQL](https://www.postgresql.org)\n- **Authentication / Authorization:** [JWT](https://jwt.io/) ### Installation Guide for `beresindev-beresin-express-backend-app`\n\n#### **Step 1: Clone the Project**\n\n```bash\n# Clone the repository from GitHub\ngit clone https://github.com/beresindev/beresindev-beresin-express-backend-app.git\n\n# Change into the project directory\ncd beresindev-beresin-express-backend-app\n```\n\n---\n\n#### **Step 2: Install Dependencies**\n\n```bash\n# Install all required npm packages\nnpm install\n# or\nyarn install\n# or\npnpm install\n# or\nbun install\n```\n\n---\n\n#### **Step 3: Configure Environment Variables**\n\n1. Copy the example environment file to create a local environment file:\n    ```bash\n    cp .env.local.example .env.local\n    ```\n\n2. Update the `.env.local` file with your specific configuration:\n\n```env\nDB_NAME=TOBEMODIFIED\nDB_HOST=TOBEMODIFIED\nDB_PORT=TOBEMODIFIED\nDB_USER=TOBEMODIFIED\nDB_PASSWORD=TOBEMODIFIED\nPORT=TOBEMODIFIED\n\nJWT_SECRET=TOBEMODIFIED\n```\n\n---\n\n#### **Step 4: Knex Migrations**\n\n**Rollback Migrations** (Optional if you need to reset):\n\n```bash\nnpx knex migrate:rollback --specific 20241101145250_create_category_services_table.ts\nnpx knex migrate:rollback --specific 20241101145251_create_service_table.ts\n```\n\n**Run Migrations**:\n\n```bash\nnpx knex migrate:up 20241101074044_create_users_table.ts --knexfile knexfile.ts\nnpx knex migrate:up 20241101145250_create_category_services_table.ts --knexfile knexfile.ts\nnpx knex migrate:up 20241101145223_create_service_table.ts --knexfile knexfile.ts\nnpx knex migrate:up 20241101145304_create_sub_category_table.ts --knexfile knexfile.ts\n```\n\n---\n\n#### **Step 5: Seed Database**\n\n```bash\n# Populate the database with an admin user\nnpx knex seed:run --specific=create_admin_user.ts\n```\n\n---\n\n#### **Step 6: Start the Application**\n\n```bash\n# Start the Express server\nnpm start\n# Access the API at http://localhost:3000\n```\n\n---\n\nThis guide provides full setup instructions for the backend application using **Express**, **JWT** for authentication, **Knex** for database migrations, and **PostgreSQL** as the database. Ensure **PostgreSQL** is configured and running.## Deployment\n\nTo deploy this project run\n\n#### 1. Copy .env.example into .env\n```bash\ncp .env.example .env\n```\n#### 2. Generate JWT_SECRET\n```bash\nopenssl rand -base64 32\n```\n\n*Output must be like this:*\n**3y9KcY0Dl1KzT9frFyM7hO0NBWwO3F5yPiB3uF9xUho=**\n\n#### 3. Update src/index.ts for production\n```bash\nimport dotenv from 'dotenv';\nimport app from './app';\n\ndotenv.config({ path: '.env' });\n\nconst PORT = parseInt(process.env.PORT || '3000', 10); // Konversi PORT ke number\nconst HOST = '0.0.0.0'; // Dengarkan di semua alamat IP agar dapat diakses secara publik\n\napp.listen(PORT, HOST, () =\u003e {\n\tconsole.log(`Server running on http://${HOST}:${PORT}`);\n});\n```\n\n#### 4. add in package.json\n```bash\n\"scripts\": {\n    \"start\": \"node dist/index.js\"\n}\n```\n#### 5. Rename Configuration ecosystem.config.js.example into ecosystem.config.js\n\nThe ecosystem.config.js file is used with PM2 (a process manager for Node.js applications) to manage and automate various aspects of running your application in production. Then fill as needed.\n```bash\nmodule.exports = {\n  apps: [\n    {\n      name: \"beresin-express-backend-app\",\n      script: \"dist/index.js\",\n      env: {\n        DB_HOST: \"TOBEMODIFIED\",\n        DB_USER: \"TOBEMODIFIED\",\n        DB_PASSWORD: \"TOBEMODIFIED\",\n        DB_NAME: \"TOBEMODIFIED\",\n        DB_PORT: TOBEMODIFIED,\n        PORT: TOBEMODIFIED,\n      },\n      env_production: {\n        NODE_ENV: \"production\"\n      }\n    }\n  ]\n};\n```\n\n#### 6. Install dependencies for production\n\nTo run Node.js applications (including compiled TypeScript applications) on a VPS continuously, you can use PM2, which is designed to run Node.js applications in production mode, keeping them running even after a server crash or restart. Here are the complete steps:\n\n#### 7. Install PM2\n```bash\nnpm install -g pm2\n```\n\n#### 8. Compile the application to JavaScript first:\n```bash\nnpx tsc\n```\n\n#### 9. using TypeScript and the entry point file is directly in src/index.js, run:\n```bash\npm2 start dist/index.js --name \"my-app\"\n```\n\n#### 10. To ensure the application continues running after a VPS restart, enable the PM2 startup feature:\n```bash\npm2 startup\n```\n\n## API Reference\n\n### 0. Miscellaneous\n\n#### **Endpoint: GET /profile**\n\n| Parameter | Type     | Description               |\n| --------- | -------- | ------------------------- |\n| None      | -        | No parameters required    |\n\nHealth check to verify database connection, size, latency, and errors.\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"Database connected successfully\",\n  \"database\": {\n    \"ready\": true,\n    \"size\": \"9329 kB\",\n    \"latency\": \"31 ms\"\n  }\n}\n```\n\n### 1. Authentication\n\n#### **Endpoint: POST /v1/auth/login**\n\n| Parameter      | Type     | Description                    |\n| -------------- | -------- | ------------------------------ |\n| `email`        | `string` | **Required**. User's email     |\n| `password`     | `string` | **Required**. User's password  |\n\n#### **Example Request Body**:\n```json\n{\n  \"email\": \"firstadmin@mail.com\",\n  \"password\": \"Admin123,\"\n}\n```\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"Login successful\",\n  \"token\": \"your_jwt_token\",\n  \"user\": {\n    \"id\": 1,\n    \"username\": \"admin\",\n    \"email\": \"firstadmin@mail.com\",\n    \"role\": \"admin\"\n  }\n}\n```\n\n---\n\n#### **Endpoint: POST /v1/auth/register**\n\n| Parameter        | Type     | Description                    |\n| ---------------- | -------- | ------------------------------ |\n| `username`       | `string` | **Required**. User's username  |\n| `name`           | `string` | **Required**. User's full name |\n| `email`          | `string` | **Required**. User's email     |\n| `phone`          | `string` | **Required**. User's phone     |\n| `password`       | `string` | **Required**. User's password  |\n\n#### **Example Request Body**:\n```json\n{\n  \"username\": \"testuser2\",\n  \"name\": \"Test User 2\",\n  \"email\": \"testuser2@example.com\",\n  \"phone\": \"123456789\",\n  \"password\": \"testpassword\"\n}\n```\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"User registered successfully\",\n  \"token\": \"your_jwt_token\",\n  \"user\": {\n    \"id\": 3,\n    \"username\": \"testuser2\",\n    \"name\": \"Test User 2\",\n    \"email\": \"testuser2@example.com\",\n    \"phone\": \"123456789\",\n    \"role\": \"User\",\n    \"created_at\": \"2024-11-02T18:49:15.231Z\",\n    \"updated_at\": \"2024-11-02T18:49:15.231Z\"\n  }\n}\n```\n\n### 2. Admin\n\n#### **Endpoint: GET /v1/admin/services**\n\nDisplays all services regardless of status (`accept`, `pending`, `decline`).\n\n| Parameter  | Type     | Description                   |\n| ---------- | -------- | ----------------------------- |\n| `api_key`  | `string` | **Required**. Admin API key   |\n\n#### **Example Response**:\n```json\n{\n  {\n    \"id\": 1,\n    \"created_at\": \"2024-11-06T05:20:14.398Z\",\n    \"updated_at\": \"2024-11-06T05:20:14.398Z\",\n    \"user_id\": 2,\n    \"isSubscription\": false,\n    \"name_of_service\": \"Title_4\",\n    \"category_id\": 3,\n    \"description\": \"Desc_4\",\n    \"status\": \"pending\",\n    \"images\": [\n      \"services/uploads/images/1730873116083-new_logo_beresin.png\",\n      \"services/uploads/images/1730873116084-old_logo_beresin.png\"\n    ] \n  ]\n}\n```\n\n---\n\n#### **Endpoint: PATCH /v1/admin/services/:id/status**\n\n| Parameter    | Type     | Description                          |\n| ------------ | -------- | ------------------------------------ |\n| `api_key`    | `string` | **Required**. Admin API key          |\n| `status`     | `string` | **Required**. Status: accept, decline, or pending |\n\n#### **Example Request Body**:\n```json\n{\n  \"status\": \"accept\"\n}\n```\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"service\": {\n    \"id\": 1,\n    \"created_at\": \"2024-11-01T18:36:42.777Z\",\n    \"updated_at\": \"2024-11-01T18:36:42.777Z\",\n    \"user_id\": 2,\n    \"isSubscription\": true,\n    \"name_of_service\": \"Jasa Design\",\n    \"category_id\": 1,\n    \"description\": \"Jasa design web dan aplikasi\",\n    \"status\": \"accept\"\n  }\n}\n```\n\n---\n\n#### **Endpoint: DELETE /v1/admin/services/:id**\n\n| Parameter  | Type     | Description                   |\n| ---------- | -------- | ----------------------------- |\n| `api_key`  | `string` | **Required**. Admin API key   |\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"Service deleted successfully\"\n}\n```\n\n---\n\n#### **Endpoint: GET /v1/admin/category**\n\n| Parameter  | Type     | Description                   |\n| ---------- | -------- | ----------------------------- |\n| `api_key`  | `string` | **Required**. Admin API key   |\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"category\": [\n    {\n      \"id\": 1,\n      \"name_of_category\": \"Technology\"\n    },\n    {\n      \"id\": 2,\n      \"name_of_category\": \"Household\"\n    },\n    {\n      \"id\": 3,\n      \"name_of_category\": \"Uncategories\"\n    }\n  ]\n}\n```\n\n---\n\n#### **Endpoint: POST /v1/admin/category**\n\n| Parameter            | Type     | Description                        |\n| -------------------- | -------- | ---------------------------------- |\n| `api_key`            | `string` | **Required**. Admin API key        |\n| `name_of_category`   | `string` | **Required**. Category name        |\n\n#### **Example Request Body**:\n```json\n{\n  \"name_of_category\": \"Technology\"\n}\n```\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"category\": {\n    \"id\": 1,\n    \"name_of_category\": \"Technology\"\n  }\n}\n```\n\n---\n\n#### **Endpoint: PUT /v1/admin/category/:id**\n\n| Parameter            | Type     | Description                        |\n| -------------------- | -------- | ---------------------------------- |\n| `api_key`            | `string` | **Required**. Admin API key        |\n| `name_of_category`   | `string` | **Required**. New category name    |\n\n#### **Example Request Body**:\n```json\n{\n  \"name_of_category\": \"Uncategories\"\n}\n```\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"category\": {\n    \"id\": 3,\n    \"name_of_category\": \"Uncategories\"\n  }\n}\n```\n\n---\n\n#### **Endpoint: DELETE /v1/admin/category/:id**\n\n| Parameter  | Type     | Description                   |\n| ---------- | -------- | ----------------------------- |\n| `api_key`  | `string` | **Required**. Admin API key   |\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"Category deleted successfully\"\n}\n```\n\n---\n\n#### **Endpoint: GET /admin/users**\n\n| Parameter | Type     | Description             |\n| --------- | -------- | ----------------------- |\n| Bearer    | `string` | **Required**. Admin JWT |\n\nRetrieves a list of all users.\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"users\": [\n    {\n      \"id\": 1,\n      \"created_at\": \"2024-11-01T17:39:05.344Z\",\n      \"updated_at\": \"2024-11-01T17:39:05.344Z\",\n      \"username\": \"admin\",\n      \"name\": \"Administrator\",\n      \"email\": \"firstadmin@mail.com\",\n      \"phone\": \"6285156644103\",\n      \"password\": \"$2b$10$VecX3hAWsU/PrHIneJkmOuCe145VdQ1pqnnNqemJq/xpu9PE2N6vu\",\n      \"role\": \"admin\"\n    },\n    {\n      \"id\": 2,\n      \"created_at\": \"2024-11-01T17:51:43.312Z\",\n      \"updated_at\": \"2024-11-07T09:06:18.308Z\",\n      \"username\": \"testuser\",\n      \"name\": \"Test User\",\n      \"email\": \"testuser@mail.com\",\n      \"phone\": \"081235595153\",\n      \"password\": \"$2b$10$sL/dFpk.K2qI6Ep88g3AtuSiBqNHAwe45Jh.eqOMnSn3gTcVZ/216\",\n      \"role\": \"User\"\n    }\n  ]\n}\n```\n\n---\n\n#### **Endpoint: POST /admin/users**\n\n| Parameter       | Type     | Description             |\n| --------------- | -------- | ----------------------- |\n| Bearer          | `string` | **Required**. Admin JWT |\n| `username`      | `string` | **Required**. Username  |\n| `name`          | `string` | **Required**. Full name |\n| `email`         | `string` | **Required**. Email     |\n| `phone`         | `string` | **Required**. Phone     |\n| `password`      | `string` | **Required**. Password  |\n| `role`          | `string` | **Required**. User role |\n\n**Example Request Body**:\n```json\n{\n  \"username\": \"newuser\",\n  \"name\": \"New User\",\n  \"email\": \"newuser@example.com\",\n  \"phone\": \"1234567890\",\n  \"password\": \"password123\",\n  \"role\": \"User\"\n}\n```\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"User created successfully\",\n  \"user\": {\n    \"id\": 9,\n    \"created_at\": \"2024-11-07T17:29:40.276Z\",\n    \"updated_at\": \"2024-11-07T17:29:40.276Z\",\n    \"username\": \"newuser\",\n    \"name\": \"New User\",\n    \"email\": \"newuser@example.com\",\n    \"phone\": \"1234567890\",\n    \"password\": \"$2b$10$Pauozt5F6Tp.Xqn5jwRkieIj4DCiXAV2tXLZFIISGgHYrBI4bVRJW\",\n    \"role\": \"User\"\n  }\n}\n```\n\n---\n\n#### **Endpoint: PUT /admin/users/:id**\n\n| Parameter       | Type     | Description               |\n| --------------- | -------- | ------------------------- |\n| Bearer          | `string` | **Required**. Admin JWT   |\n| `username`      | `string` | **Required**. New username |\n| `name`          | `string` | **Required**. New name    |\n| `email`         | `string` | **Required**. New email   |\n| `phone`         | `string` | **Required**. New phone   |\n| `password`      | `string` | **Required**. New password|\n| `role`          | `string` | **Required**. New role    |\n\n**Example Request Body**:\n```json\n{\n  \"username\": \"testuser3\",\n  \"name\": \"Test User 3\",\n  \"email\": \"testuser3@mail.com\",\n  \"phone\": \"08123345445789\",\n  \"password\": \"testpassword\",\n  \"role\": \"User\"\n}\n```\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"User updated successfully\",\n  \"user\": {\n    \"id\": 9,\n    \"created_at\": \"2024-11-07T17:29:40.276Z\",\n    \"updated_at\": \"2024-11-07T17:31:25.751Z\",\n    \"username\": \"testuser3\",\n    \"name\": \"Test User 3\",\n    \"email\": \"testuser3@mail.com\",\n    \"phone\": \"08123345445789\",\n    \"password\": \"$2b$10$tWFd84.ayz7YAjQJAW1BJu3tppdBnoLvrpzIntEQeUrnTrLeq/W3O\",\n    \"role\": \"User\"\n  }\n}\n```\n\n---\n\n#### **Endpoint: DELETE /admin/users/:id**\n\n| Parameter | Type     | Description             |\n| --------- | -------- | ----------------------- |\n| Bearer    | `string` | **Required**. Admin JWT |\n\nDeletes a user and their related data.\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"User 'Test User 3' and related services and images deleted successfully\"\n}\n```\n\n---\n\n### 3. User\n\n#### **Endpoint: GET /user/profile**\n\n| Parameter | Type     | Description             |\n| --------- | -------- | ----------------------- |\n| Bearer    | `string` | **Required**. User JWT  |\n\nRetrieves profile information of the authenticated user.\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"User profile retrieved successfully\",\n  \"user\": {\n    \"id\": 6,\n    \"username\": \"seconduser\",\n    \"name\": \"Second User\",\n    \"email\": \"second@example.com\",\n    \"phone\": \"086289789612\",\n    \"role\": \"User\",\n    \"created_at\": \"2024-11-07T09:11:15.577Z\",\n    \"updated_at\": \"2024-11-07T09:11:15.577Z\"\n  }\n}\n```\n\n---\n\n#### **Endpoint: DELETE /user/deleteAccount**\n\n| Parameter | Type     | Description             |\n| --------- | -------- | ----------------------- |\n| Bearer    | `string` | **Required**. User JWT  |\n\nDeletes the user account and all related data.\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"Account and all related content deleted successfully\"\n}\n```\n\n---\n\n#### **Endpoint: GET /v1/user/services**\n\n| Parameter  | Type     | Description                   |\n| ---------- | -------- | ----------------------------- |\n| `api_key`  | `string` | **Required**. User API key   |\n\nReturns all services belonging to the authenticated user, unique to each user.\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"services\": [\n    {\n      \"id\": 1,\n      \"created_at\": \"2024-11-01T18:36:42.777Z\",\n      \"updated_at\": \"2024-11-01T18:36:42.777Z\",\n      \"user_id\": 2,\n      \"isSubscription\": true,\n      \"name_of_service\": \"Jasa Design\",\n      \"category_id\": 1,\n      \"description\": \"Jasa design web dan aplikasi\",\n      \"status\": \"accept\",\n      \"images\": [\n        \"services/uploads/images/1730568201772-WhatsApp Image 2024-11-02 at 17.58.44.jpeg\",\n        \"services/uploads/images/1730568201773-ttd-halim.png\"\n      ]\n    }\n  ]\n}\n```\n\n---\n\n#### **Endpoint: POST /user/services**\n\n| Parameter          | Type      | Description                  |\n| ------------------ | --------- | ---------------------------- |\n| Bearer             | `string`  | **Required**. User JWT       |\n| `name_of_service`  | `string`  | **Required**. Name of the service |\n| `category_id`      | `integer` | **Required**. ID of the category |\n| `description`      | `string`  | **Required**. Description of the service |\n| `images`           | `String`  | **Required**. Images of the service |\n\n**Note**: This endpoint requires `multipart/form-data` for file upload. The `images` field accepts up to 2 image files.\n\n**Example Request Body**:\n```json\n{\n  \"name_of_service\": \"Jasa Mengajar Next.js\",\n  \"category_id\": 3,\n  \"description\": \"Mengajar Coding dari Javascript dasar, Typescript, hingga React.Js\",\n  \"images\": [\"Background.png\", \"BeresIn Flow.png\"]\n}\n```\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"service\": {\n    \"id\": 11,\n    \"created_at\": \"2024-11-04T09:44:53.352Z\",\n    \"updated_at\": \"2024-11-04T09:44:53.352Z\",\n    \"user_id\": 2,\n    \"isSubscription\": false,\n    \"name_of_service\": \"Jasa Mengajar Next.js\",\n    \"category_id\": 3,\n    \"description\": \"Mengajar Coding dari Javascript dasar, Typescript, hingga React.Js\",\n    \"status\": \"pending\",\n    \"images\": [\n      {\n        \"id\": 13,\n        \"image\": \"services/uploads/images/1730713493349-Background.png\",\n        \"service_id\": 11\n      },\n      {\n        \"id\": 14,\n        \"image\": \"services/uploads/images/1730713493349-BeresIn Flow.png\",\n        \"service_id\": 11\n      }\n    ]\n  }\n}\n```\n\n---\n\n#### **Endpoint: PUT /user/services/:id**\n\n| Parameter          | Type      | Description                  |\n| ------------------ | --------- | ---------------------------- |\n| Bearer             | `string`  | **Required**. User JWT       |\n| `name_of_service`  | `string`  | **Required**. Name of the service |\n| `category_id`      | `integer` | **Required**. ID of the category |\n| `description`      | `string`  | **Required**. Description of the service |\n| `images`           | `String`  | **Optional**. Updated images of the service |\n\n**Note**: This endpoint also requires `multipart/form-data` for file upload. The `images` field accepts up to 2 image files.\n\n**Example Request Body**:\n```json\n{\n  \"name_of_service\": \"Jasa Perbaikan Laptop\",\n  \"category_id\": 1,\n  \"description\": \"Service and repair for laptops, including software and hardware issues\",\n  \"images\": [\"laptop-repair1.png\", \"laptop-repair2.png\"]\n}\n```\n---\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"service\": {\n    \"id\": 2,\n    \"created_at\": \"2024-11-02T19:19:18.752Z\",\n    \"updated_at\": \"2024-11-07T19:19:18.752Z\",\n    \"user_id\": 3,\n    \"isSubscription\": true,\n    \"name_of_service\": \"Jasa Perbaikan Laptop\",\n    \"category_id\": 1,\n    \"description\": \"Service and repair for laptops, including software and hardware issues\",\n    \"status\": \"accept\",\n    \"images\": [\n      {\n        \"id\": 15,\n        \"image\": \"services/uploads/images/1730713493349-laptop-repair1.png\",\n        \"service_id\": 2\n      },\n      {\n        \"id\": 16,\n        \"image\": \"services/uploads/images/1730713493349-laptop-repair2.png\",\n        \"service_id\": 2\n      }\n    ]\n  }\n}\n```\n\n---\n\n#### **Endpoint: DELETE /user/services/:id**\n\n| Parameter | Type     | Description             |\n| --------- | -------- | ----------------------- |\n| Bearer    | `string` | **Required**. User JWT  |\n\nDeletes a specified service belonging to the authenticated user.\n\n**Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"Service deleted successfully\"\n}\n```\n\n---\n\n#### **Endpoint: GET /user/category**\n\n| Parameter  | Type     | Description                   |\n| ---------- | -------- | ----------------------------- |\n| `api_key`  | `string` | **Required**. User API key    |\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"category\": [\n    {\n      \"id\": 1,\n      \"name_of_category\": \"Technology\"\n    },\n    {\n      \"id\": 2,\n      \"name_of_category\": \"Household\"\n    },\n    {\n      \"id\": 3,\n      \"name_of_category\": \"Uncategories\"\n    }\n  ]\n}\n```\n\n---\n\n### 4. Public\n\n#### **Endpoint: GET /services/all**\n\nOnly services with `status: accept` are displayed.\n\n| Parameter | Type     | Description               |\n| --------- | -------- | ------------------------- |\n| None      | -        | No parameters required    |\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"services\": [\n    {\n      \"id\": 1,\n      \"created_at\": \"2024-11-01T18:36:42.777Z\",\n      \"updated_at\": \"2024-11-01T18:36:42.777Z\",\n      \"user_id\": 2,\n      \"isSubscription\": true,\n      \"name_of_service\": \"Jasa Design\",\n      \"category_id\": 1,\n      \"description\": \"Jasa design web dan aplikasi\",\n      \"status\": \"accept\",\n      \"images\": [\n        \"services/uploads/images/1730568201772-WhatsApp Image 2024-11-02 at 17.58.44.jpeg\",\n        \"services/uploads/images/1730568201773-ttd-halim.png\"\n      ],\n      \"phone\": \"081235595153\"\n    }\n  ]\n}\n```\n\n---\n\n#### **Endpoint: GET /category**\n\n| Parameter | Type     | Description               |\n| --------- | -------- | ------------------------- |\n| None      | -        | No parameters required    |\n\n#### **Example Response**:\n```json\n{\n  \"status\": \"success\",\n  \"category\": [\n    {\n      \"id\": 1,\n      \"name_of_category\": \"Technology\"\n    },\n    {\n      \"id\": 2,\n      \"name_of_category\": \"Household\"\n    },\n    {\n      \"id\": 3,\n      \"name_of_category\": \"Uncategories\"\n    }\n  ]\n}\n```\n## Used By\n\nThis project is used by the following companies:\n\n- [Agile Teknik](https://agileteknik.com)\n- [PENS](https://pens.id)\n\n## Support\n\nFor support, email teambersin@gmail.com.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberesindev%2Fberesin-express-backend-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberesindev%2Fberesin-express-backend-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberesindev%2Fberesin-express-backend-app/lists"}