Giter Site home page Giter Site logo

yogahilmi / mykost-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 18.34 MB

Backend service for MyKost where users can search kost that have been added by the owner. Also, users can ask about room availability using the credit system.

Shell 0.01% PHP 0.80% JavaScript 93.28% Blade 0.25% CSS 5.67%

mykost-api's Introduction

About Project

This is a simple API for user can search kost for room that have been added by owner. Also, user can ask about room availability using credit system.

Regular user will have 20 credit and premium user will have 40 credit per month.

Project Requirement

  1. Regular user will be given 20 credit, premium user will be given 40 credit after register.
  2. Owner will have no credit.
  3. Owner can add more than 1 kost
  4. Search kost by several criteria: name, location, price
  5. Search kost sorted by: price
  6. Ask about room availability will reduce user credit by 5 point
  7. Owner API & ask room availability API need to have authentication
  8. Implement scheduled command to recharge user credit on every start of the month

Prerequisites

  1. PHP 7.3.28
  2. Laravel 8.83.7
  3. Laravel Sanctum for Authentication
  4. Composer
  5. MySQL

Scheduling Task

This project also implement scheduled command to recharge user credit on every start of the month named monthly:recharge.

To run scheduling task you can use Crontab:

  1. Open crontab file
    crontab -e
  1. Edit crontab file and add
    0 0 1 * * cd /your-project-path && php artisan monthly:recharge >> /dev/null 2>&1

Setup Guide

  1. Clone this Repo
    git clone https://github.com/yogahilmi/mykost-api.git
  1. Copy file .env.example and rename it to .env
    cp .env.example .env
  1. Edit .env, fill DB setting and save

  2. Migrate DB

    php artisan migrate
  1. Run the project, to open port 8000
    php artisan serve

Because the web server runs only one single-threaded process, so PHP applications will stall if a request is blocked.

  1. Run the project again with other terminal, to open port 8001 for API Call
    php artisan serve

Owner Dashboard

Owner Dashboard using for management kost with CRUD. Owner can view his kost, create, update and delete. To open Dashboard, please access below :

    http://localhost:8000

You can login as owner or create new user.

API Documentation

Auth /api/auth

Register User

POST /api/auth/register

Body:

{
    "name": "Yoga Hilmi Tasanah",
    "email": "[email protected]",
    "password": "12345678",
    "role": 0
}

Login User

POST /api/auth/login

Body:

{
    "email": "[email protected]",
    "password": "12345678"
}

Logout User

POST /api/auth/logout

Authorization: Bearer Token

Kost /api/kosts/

Create New Kost

POST /api/kosts/create

Authorization: Bearer Token

Body:

{
    "name" : "Kost Murah",
    "location" : "Jakarta",
    "price" : 950000,
    "description" : "Kost dengan fasilitas lengkap di pusat kota"
}

Update Kost Detail

PUT /api/kost/edit/{id}

Authorization: Bearer Token

Body:

{
    "name" : "Kost Murah",
    "location" : "Jakarta",
    "price" : 950000,
    "description" : "Kost dengan fasilitas lengkap di pusat kota"
}

Delete Kost

DELETE /api/kost/edit/{id}

Authorization: Bearer Token

Show Kost Data By Owner

GET /api/kost/data/list

Authorization: Bearer Token

Show All Kost Data

GET /api/kost/

Show Kost Data By ID

GET /api/kost/{id}

Authorization: Bearer Token

Search Kost Data By Params

GET /api/kost/search

Authorization: Bearer Token

Body:

{
    "name" : "",
    "location" : "",
    "price" :
}

Room Availability /api/availability

Ask Availability

POST /api/availability/kost/{id}/ask

Authorization: Bearer Token

Give Availability

POST /api/availability/{id}/give

Authorization: Bearer Token

Body:

{
    "is_available" : 1
}

Show Availability By ID

GET /api/availability/kost/{id}

Authorization: Bearer Token

Show All Availability

GET /api/availability

Authorization: Bearer Token

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.