Coder Social home page Coder Social logo

dtech-dbug / fcc-exercise-tracker-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 33 KB

An API that keeps tracks of Users mapped to their exercises and also shows logs. Made w/ Node,Express,MongoDB.

CSS 12.05% Shell 0.13% JavaScript 60.69% HTML 27.13%
nodejs expressjs mongodb mongoose freecodecamp freecodecamp-challenge freecodecamp-backend

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)

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.