ichungelo / movie_app_server

server for movie app to accomplish daily task in refactory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REST API WITH ECHO

TOOLS


REPOSITORY


MIGRATION DATABASE

MIGRATE UP

migrate -path migrations/ -database 'mysql://{user}:{password}@tcp({host}:{port})/dbname?query' -verbose up

MIGRATE DOWN

migrate -path migrations/ -database 'mysql://{user}:{password}@tcp({host}:{port})/dbname?query' -verbose down

SEED DATABASE

mysql -u user -p movie_app < migrations/seeds/*.sql

STEP BY STEP

  • create db name movie_app
  • then run command below :
$ mysql -u {dbUser} -p movie_app < migrations/seeds/*.sql
$ go run .

RUN SERVER

go run .

RUN SWAGGER

API SPEC

Register Account

Request:

  • Endpoint: /api/auth/register
  • Method: POST
  • Body:
    {
        "username": "string",
        "email": "string",
        "first_name": "string",
        "last_name": "string",
        "password": "string",
        "confirm_password": "string"
    }

Response:

  • body:
    {
        "success": "boolean",
        "message": "string"
    }

Login Account

Request:

  • Endpoint: /api/auth/login
  • Method: POST
  • Body:
    {
        "username": "string",
        "password": "string"
    }

Response:

  • body:
    {
        "success": "boolean",
        "message": "string",
        "token": "JWT"
    }

Get All Movies

Request:

  • Endpoint: /api/movies
  • Method: GET

Response:

  • body:
    {
        "success": "boolean",
        "message": [
          {
            "movie_id": "int"
            "title": "string"
            "release_year": "year"
            "production": "endpoint"
            "overview": "text"
          },
          {
            "movie_id": "int"
            "title": "string"
            "release_year": "year"
            "production": "endpoint"
            "overview": "text"
          },...
        ]
    }

Post Movie By Id

Request:

  • Endpoint: /api/movies/{movieId}
  • Method: GET

Response:

  • body:
    {
      "success": "boolean",
      "message": {
          "movie_id": "int",
          "title": "string",
          "year": "year",
          "poster": "endpoint",
          "overview": "string",
          "reviews": [
            {
              "review_id": "int",
              "username": "string",
              "review": "string",
            },
            {
              "review_id": "int",
              "username": "string",
              "review": "string",
            },...
          ]
        }
    }

Post Review

Request:

  • Endpoint: /api/movies/{movieId}/review
  • Method: POST
  • Body:
    {
        "review": "string",
    }

Response:

  • body:
    {
        "success": "boolean",
        "message": "string"
    }

Update Review

Request:

  • Endpoint: /api/movies/{movieId}/review/{reviewId}
  • Method: PUT
  • Body:
    {
        "review": "string",
    }

Response:

  • body:
    {
        "success": "boolean",
        "message": "string"
    }

Delete Review

Request:

  • Endpoint: /api/movies/{movieId}/review/{reviewId}
  • Method: DELETE

Response:

  • body:
    {
        "success": "boolean",
        "message": "string"
    }
graph TD
  A([A])-->B[/B/]
  B-->C{C}
  C-->|yes|D([D])
  C-->|no|E([E])
Loading

About

server for movie app to accomplish daily task in refactory


Languages

Language:Go 82.4%Language:HTML 14.3%Language:JavaScript 2.1%Language:CSS 0.8%Language:Shell 0.3%