$ npm i
$ npm run dev
$ knex migrate:latest
$ knex seed:run
GET /
- Method : GET
- Header :
- Content-Type: application/html
- Accept: application/html
Render sebuah landing page
GET /cars
- Method : GET
- Header :
- Content-Type: application/html
- Accept: application/html
Mengembalikan list cars, dengan beberapa query string :
- driver : Filter berdasarkan sewa mobil memiliki supir atau tidak
- tanggal : Filter sewa mobil berdasarkan tanggal
- waktu : Filter sewa mobil berdasarkan jam
- jumlah(optional) : Filter sewa mobil berdasarkan kapasitas mobil
GET /cars?driver=true&tanggal=2023-11-14&waktu=12&jumlah=
render cars.html beserta daftar mobil yang tersedia berdasarkan filter
POST /login
- Method : POST
- Header :
- Content-Type: application/json
- Accept: application/json
- Body
{
"email": "[email protected]",
"password": "superadmin"
}
status code 200
{
"token": "string"
}
GET api/cars
- Method : GET
- Header:
- Content-Type: application/json
- Authorization: Bearer token
status code 200
[
{
"id": "6e2bc663-5197-441a-957b-bc75e4a2da7c",
"plate": "DBH-3491",
"manufacture": "Ford",
"model": "F150",
"image": "./images/car01.min.jpg",
"rentPerDay": 200000,
"capacity": 2,
"description": " Brake assist. Leather-wrapped shift knob. Glove box lamp. Air conditioning w/in-cabin microfilter.",
"availableAt": "2023-11-27T05:00:00.000Z",
"transmission": "Automatic",
"available": true,
"type": "Sedan",
"driver": false,
"year": 2022,
"options": [
"Cruise Control",
"Tinted Glass",
"Tinted Glass",
"Tinted Glass",
"AM/FM Stereo"
],
"specs": [
"Brake assist",
"Leather-wrapped shift knob",
"Glove box lamp",
"Air conditioning w/in-cabin microfilter",
"Body color folding remote-controlled pwr mirrors",
"Dual-stage front airbags w/occupant classification system"
],
"created_at": "2023-11-22T17:01:41.814Z",
"updated_at": null,
"deleted_at": null,
"created_by": 1,
"updated_by": null,
"deleted_by": null
},
{
"id": "9ff03bbc-b18c-4ba7-8f3a-4c4b5c2f6c77",
"plate": "WXB-3984",
"manufacture": "BMW",
"model": "X5",
"image": "./images/car02.min.jpg",
"rentPerDay": 800000,
"capacity": 6,
"description": " Rear passenger map pockets. Electrochromic rearview mirror. Dual chrome exhaust tips. Locking glove box.",
"availableAt": "2023-11-27T08:00:00.000Z",
"transmission": "Automatic",
"available": false,
"type": "Convertible",
"driver": true,
"year": 2019,
"options": [
"Keyless Entry",
"Power Windows",
"MP3 (Single Disc)",
"CD (Multi Disc)",
"Navigation"
],
"specs": [
"Rear passenger map pockets",
"Electrochromic rearview mirror",
"Dual chrome exhaust tips",
"Locking glove box",
"Pwr front vented disc/rear drum brakes"
],
"created_at": "2023-11-22T17:01:41.814Z",
"updated_at": null,
"deleted_at": null,
"created_by": 1,
"updated_by": null,
"deleted_by": null
},
]
Mengembalikan satu mobil berdasarkan id mobil
GET api/cars/:id
- Method : GET
- Header:
- Content-Type: application/json
- Authorization: Bearer token
{
"id":"08cbd537-497f-4305-b7b4-e7493c703a2c",
"plate":"ZAG-8112",
"manufacture":"Ford",
"model":"F150","image":"./images/car19.min.jpg",
"rentPerDay":600000,
"capacity":6,
"description":"",
"availableAt":"2023-11-17T05:00:00.000Z",
"transmission":"Automatic",
"available":false,
"type":"Convertible",
"driver":true,
"year":2021,
"options":[
"CD (Single Disc)",
"Airbag: Driver",
],
"specs":["All-position 3-point seat belts -inc: outboard pretensioners & force limiters"]
}
Membuat mobil baru
POST api/cars
- Method : POST
- Header:
- Content-Type: application/json
- Authorization: Bearer token
- Body
{
"id": "9ff03bbc-b18c-4ba7-8f3a-4c4b5c2f6c77",
"plate": "WXB-3984",
"manufacture": "BMW",
"model": "X5",
"image": "./images/car02.min.jpg",
"rentPerDay": 800000,
"capacity": 6,
"description": " Rear passenger map pockets. Electrochromic rearview mirror. Dual chrome exhaust tips. Locking glove box.",
"availableAt": "2023-11-27T08:00:00.000Z",
"transmission": "Automatic",
"available": false,
"type": "Convertible",
"driver": true,
"year": 2019,
"options": [
"Keyless Entry",
"Power Windows",
"MP3 (Single Disc)",
"CD (Multi Disc)",
"Navigation"
],
"specs": [
"Rear passenger map pockets",
"Electrochromic rearview mirror",
"Dual chrome exhaust tips",
"Locking glove box",
"Pwr front vented disc/rear drum brakes"
],
}
status code 200
{
"plate": "DBH-3491",
"manufacture": "Ford",
"model": "F150",
...
"id": "08cbf532-497f-4305-b7b4-e7434c703a2c",
}
Mengedit Mobil berdasarkan id
Patch api/cars/:id
- Method : PATCH
- Header:
- Content-Type: application/json
- Authorization: Bearer token
- Body
{
"plate": "DBH-3491 edit",
"manufacture": "Ford",
"model": "F150",
...
}
status code 200 data: { "plate": "DBH-3491 edit", "manufacture": "Ford", "model": "F150", ... }
Menghapus Mobil berdasarkann id
DElETE cars/:id
- Method : DELETE
- Header:
- Content-Type: application/json
- Authorization: Bearer token
status code 200
{}