Git Product home page Git Product logo

fcc-exercise-tracker-api's Introduction

Schema Design

//user schema
let userSchema = Schema({
  username: String,
});

//exercise schema
let exerciseSchema = new Schema({
  username: String,
  description: { type: String, required: true },
  duration: { type: Number, required: true },
  date: String,
});

//logs schema
let logsSchema = new Schema({
  username: String,
  count: Number,
  log: [
    {
      _id: false,
      description: String,
      duration: Number,
      date: String,
    },
  ],
});

Endpoints and Responses

Create User

  • endpoint: "/api/users"
  • method: POST

Get Users

  • endpoint: "/api/users"
  • method: GET
  • response ๐Ÿ‘‡
[
  {
    _id: "61980e4e3fa3d93818ee5f4d",
    username: "Dtech-Dbug",
  },
  {
    _id: "61980e573fa3d93818ee5f4f",
    username: "scorpiohnoo",
  },
];

Create Exercise

  • endpoint: "/api/users/:id/exercises"
  • method: POST

Get Exercises based on users

  • endpoint: "/api/users/:id/exercises"
  • method: GET
  • response ๐Ÿ‘‡
[
  {
    _id: "61982245e6b2750c9df084ad",
    username: "scorpiohnoo",
    description: "sleep",
    duration: 7,
    date: "Fri Nov 19 2021",
    __v: 0,
  },
  {
    _id: "61994ee86500318eb70e2a95",
    username: "scorpiohnoo",
    description: "code",
    duration: 60,
    date: "Sat Nov 20 2021",
    __v: 0,
  },
];

Get user specific Logs

  • endpoint: /api/users/:id/logs
  • method: GET
  • response ๐Ÿ‘‡
{
  "username": "scorpiohnoo",
  "count": 3,
  "log": [
    {
      "description": "sleep",
      "duration": 7,
      "date": "function toDateString() { [native code] }"
    },
    {
      "description": "sleep",
      "duration": 7,
      "date": "Fri Nov 19 2021"
    },
    {
      "description": "code",
      "duration": 60,
      "date": "Sat Nov 20 2021"
    }
  ],
  "_id": "619963a366ea8ac7270995bc",
  "__v": 0
}

Find the hosted link to Replit:(https://fcc-exercisetracker.dwaipayanchakro.repl.co)

fcc-exercise-tracker-api's People

Contributors

abhijeetps avatar arturjzapater avatar dtech-dbug avatar energydev avatar gikf avatar huyenltnguyen avatar jeremies avatar josephlivengood avatar mot01 avatar scissorsneedfoodtoo 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.