Coder Social home page Coder Social logo

gigih-midterm's Introduction

gigih-midterm

Table of Contents

Database Structure

Database Structure

There's 3 table in this database, whic is videos, products, and comments. Im not using users table yet, because i want to make it simple, like the requirement, where i just have to input the username directly in the comment form.

API Documentation

Videos

Method Endpoint Description
POST /videos Create new video
GET /videos Get all videos

POST /videos

Object

  • URL Params: None

  • Data Params:

    {
      "thumbnail": "https://www.google.com",
      "title": "Test"
    }
  • Headers: Content-Type: application/json

  • Success Response:

    • Code: 201
    • Content:
    {
      "id": "b3db7910-b4c5-4d84-b227-e85a2ddd0190",
      "thumbnail": "https://www.google.com",
      "title": "Test",
      "_id": "64c31f103ffa7837f557254a",
      "__v": 0
    }

GET /videos

Object

  • URL Params: None
  • Data Params: None
  • Headers: Content-Type: application/json
  • Success Response:
    • Code: 200
    • Content:
    [
      {
        "_id": "64c27c31a5483241119657ac",
        "id": "cec43a0c-6694-49cf-8b7c-3a64aa8da665",
        "thumbnail": "https://www.google.com"
      }
    ]

Comments

Method Endpoint Description
POST /comments/:videoId Create new comment
GET /comments/:videoId Get all comments

POST /comments

Object

  • URL Params: None
  • Data Params:
    {
      "username": "test",
      "comment": "test"
    }
  • Headers: Content-Type: application/json
  • Success Response:
    • Code: 201
    • Content:
    {
      "videoId": "64c27c31a5483241119657ac",
      "comment": "Testt",
      "createdAt": "2023-07-28T01:51:36.825Z",
      "_id": "64c31f283ffa7837f557254c",
      "__v": 0
    }

GET /comments

  • URL Params: None
  • Data Params: None
  • Headers: Content-Type: application/json
  • Success Response:
    • Code: 200
    • Content:
    [
      {
        "_id": "64c29d6ab53f6889523a217a",
        "comment": "Halo",
        "username": "Test",
        "createdAt": "2023-07-27T16:38:02.119Z"
      },
      {
        "_id": "64c29da6b53f6889523a217d",
        "comment": "Velldy Cantik",
        "username": "Velldy Cantik",
        "createdAt": "2023-07-27T16:39:02.381Z"
      }
    ]

Products

Method Endpoint Description
POST /products/:videoId Create new product
GET /products/:videoId Get all products

POST /products

  • URL Params: None
  • Data Params:
    {
      "link": "test2",
      "title": "test2",
      "price": "Rp.155.000"
    }
  • Headers: Content-Type: application/json
  • Success Response:
    • Code: 201
    • Content:
    {
      "id": "95da74a9-6309-416b-ab60-b9a822c01f7d",
      "link": "test2",
      "title": "test2",
      "price": "Rp.155.000",
      "videoId": "cec43a0c-6694-49cf-8b7c-3a64aa8da665",
      "_id": "64c28271685a264e5859524c",
      "__v": 0
    }

GET /products

  • URL Params: None
  • Data Params: None
  • Headers: Content-Type: application/json
  • Success Response:
    • Code: 200
    • Content:
    [
      {
        "_id": "64c2815c79c9debcccc97afa",
        "id": "a6365de1-07da-4dfb-bae3-e552625efcdb",
        "link": "test",
        "title": "test",
        "price": "test"
      },
      {
        "_id": "64c28271685a264e5859524c",
        "id": "95da74a9-6309-416b-ab60-b9a822c01f7d",
        "link": "test2",
        "title": "test2",
        "price": "Rp.155.000"
      }
    ]

How to run

1. Clone this repo
2. Run `npm install`
3. Change the `.env.example` to `.env` and fill the value with your own mongodb url
4. Run `npm start`
5. Open `http://localhost:3000` in your browser
6. Enjoy!

gigih-midterm's People

Contributors

dendianugerah avatar

Watchers

 avatar

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.