Skip to content

Commit

Permalink
Merge pull request #3 from Bangkit-Capstone-2024/development
Browse files Browse the repository at this point in the history
Merge Development
  • Loading branch information
RobyYasirAmri authored Jun 14, 2024
2 parents c4e31c9 + a3fd082 commit 5614a6e
Show file tree
Hide file tree
Showing 42 changed files with 2,656 additions and 819 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ ZOHO_PASSWORD=yourpassword ## change this to your password
## Upload to GCS

GOOGLE_APPLICATION_CREDENTIALS=<path to your service account json file>
GCS_BUCKET_NAME=<your bucket name>
GCS_BUCKET_NAME=<your bucket name>

## GMAPS
GOOGLE_MAPS_API_KEY=<your MAPS API KEY>
50 changes: 50 additions & 0 deletions .github/workflows/deploy-to-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI/CD Pipeline Development

on:
push:
branches:
- development

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20.14.0' # Ubah ke versi Node.js yang Anda gunakan

- name: Install dependencies
run: npm install

- name: Build project
run: npm run build

deploy-to-development:
if: github.ref == 'refs/heads/development'
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Add SSH key
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.DEV_SERVER_SSH_KEY }}

- name: Add development server to known hosts
run: |
ssh-keyscan -H ${{ secrets.DEV_SERVER_IP }} >> ~/.ssh/known_hosts
- name: Deploy to Development Server
env:
SERVER_IP: ${{ secrets.DEV_SERVER_IP }}
SERVER_USERNAME: ${{ secrets.DEV_USERNAME}}
run: |
ssh $SERVER_USERNAME@$SERVER_IP 'export NVM_DIR="$HOME/.nvm" && source "$NVM_DIR/nvm.sh" && nvm use v20.14.0 && cd ~/dev-momee && git pull && npm install && npx prisma migrate deploy && npm run build && pm2 restart dev-momee && pm2 describe dev-momee'
47 changes: 47 additions & 0 deletions .github/workflows/deploy-to-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI/CD Pipeline Production

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20.14.0' # Ubah ke versi Node.js yang Anda gunakan

- name: Install dependencies
run: npm install

- name: Build project
run: npm run build

deploy-to-production:
if: github.ref == 'refs/heads/master'
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Add SSH key
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.PROD_SERVER_SSH_KEY }}

- name: Deploy to Development Server
env:
SERVER_IP: ${{ secrets.PROD_SERVER_IP }}
SERVER_USERNAME: ${{ secrets.PROD_USERNAME}}
run: |
ssh $SERVER_USERNAME@$SERVER_IP 'cd ~/prod-momee && git pull && npm install && npx prisma migrate deploy && npm run build && pm2 restart prod-momee && pm2 describe prod-momee'
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,14 @@ f. Click 'Manage keys'
g. Click Add Key > Create new key
h. Choose 'JSON' and 'Create'
i. Download JSON File and Save
j. create and save JSON file to new Folder : `mkdir credeentials`
j. create and save JSON file to new Folder : `mkdir credentials`
```

6. Edit .env

```
GOOGLE_APPLICATION_CREDENTIALS=./credentials/<service-account.json>
GCS_BUCKET_NAME=<BUCKET-NAME>
GOOGLE_MAPS_API_KEY=<your-MAPS-API-KEY>
```

## User Model

## Tenants Model

## Product Model

## Rent Model

## Category Model
227 changes: 227 additions & 0 deletions docs/Booking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# Booking API Spec

> User dapat melakukan booking sesuai dengan stock barang yang tersedia
<details><summary>Create New Booking</summary>

> Ketika membuat booking baru, harga akan otomatis menyesuaikan/menjumlahkan sesuai dengan `startDate` dan `endDate` dari user.
### Endpoint : ```POST /api/v1/bookings```

Request Headers :

```
Key: Authorization
Value: Baerer <token>
```

Request Body :

```JSON
{
"product_id" : "1",
"startDate" : "2024-06-10",
"endDate" : "2024-06-16"
}

```
Response Body Success :

```json

{
"success": "true",
"message": "Booking created successfully",
"data": {
"id": 5,
"startDate": "2024-06-10T00:00:00.000Z",
"endDate": "2024-06-16T00:00:00.000Z",
"totalPrice": 51000,
"user_id": 1,
"product_id": 1,
"created_at": "2024-06-09T14:46:43.688Z",
"updated_at": "2024-06-09T14:46:43.688Z"
}
}
```

Response Body Error :

> Jika product id tidak ada
```json

{
"success": "false",
"message": "Product not available"
}

```

> Jika stock product habis
```json
{
"success": "false",
"message": "Product is out of stock"
}

```

</details>

<details><summary>Get Booking by User</summary>

>
### Endpoint : ```GET /api/v1/bookings```

Request Headers :

```
Key: Authorization
Value: Baerer <token>
```

Response Body Success :

```json

{
"success": "true",
"data": [
{
"id": 4,
"startDate": "2024-06-10T00:00:00.000Z",
"endDate": "2024-06-16T00:00:00.000Z",
"totalPrice": 51000,
"user_id": 1,
"product_id": 1,
"created_at": "2024-06-08T18:09:04.690Z",
"updated_at": "2024-06-08T18:09:04.690Z",
"product": {
"id": 1,
"name_products": "Ride On 2 test",
"slug": "ride-on-2-test-846c3f67",
"pictures": "[\"https://storage.googleapis.com/dev-momee-products-images/Roby Stores Update 2/0c969e2d9b5cd968c62705264c94ba0c-ride-on.jpg\"]",
"description": "Example Description Product",
"price": 8500,
"stock": 8,
"is_available": true,
"created_at": "2024-06-07T18:56:16.669Z",
"updated_at": "2024-06-09T15:26:05.455Z",
"category_id": 1,
"tenant_id": 2,
"address_tenants": "Kota Semarang, Jawa Tengah, Indonesia",
"tenant": {
"id": 2,
"user_id": 1,
"name_tenants": "Roby Stores Update 2",
"address_tenants": "Kota Semarang, Jawa Tengah, Indonesia"
}
}
},
]
}
```

</details>


<details><summary>Get Booking by Id</summary>

>
### Endpoint : ```GET /api/v1/bookings/:id```

Request Headers :

```
Key: Authorization
Value: Baerer <token>
```

Response Body Success :


```json

{
"success": "true",
"data": {
"id": 4,
"startDate": "2024-06-10T00:00:00.000Z",
"endDate": "2024-06-16T00:00:00.000Z",
"totalPrice": 51000,
"user_id": 1,
"product_id": 1,
"created_at": "2024-06-08T18:09:04.690Z",
"updated_at": "2024-06-08T18:09:04.690Z",
"product": {
"id": 1,
"name_products": "Ride On 2 test",
"slug": "ride-on-2-test-846c3f67",
"pictures": "[\"https://storage.googleapis.com/dev-momee-products-images/Roby Stores Update 2/0c969e2d9b5cd968c62705264c94ba0c-ride-on.jpg\"]",
"description": "Example Description Product",
"price": 8500,
"stock": 7,
"is_available": true,
"created_at": "2024-06-07T18:56:16.669Z",
"updated_at": "2024-06-09T14:56:55.654Z",
"category_id": 1,
"tenant_id": 2,
"address_tenants": "Kota Semarang, Jawa Tengah, Indonesia"
},
"user": {
"id": 1,
"email": "robyyasiramri@gmail.com",
"username": "Roby Yasir"
}
}
}
```

Response Body Error :

```json
{
"success": "false",
"message": "Booking not found"
}
```

</details>

<details><summary>Delete/Cancel Booking</summary>

>
### Endpoint : ```DELETE /api/v1/bookings```

Request Headers :

```
Key: Authorization
Value: Baerer <token>
```

Response Body Success :

```json

{
"success": "true",
"message": "Booking canceled successfully"
}
```

Response Body Error :

```json
{
"success": "false",
"message": "Booking not found or already canceled!"
}
```

</details>
Loading

0 comments on commit 5614a6e

Please sign in to comment.