-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Bangkit-Capstone-2024/development
Merge Development
- Loading branch information
Showing
42 changed files
with
2,656 additions
and
819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.