Code Monkey home page Code Monkey logo

bossmachine's People

Contributors

simonapiz avatar

Watchers

 avatar

bossmachine's Issues

Bonus

Bonus

As a bonus, you may implement routes to allow bosses to add and remove work from their minions' backlogs.

Schema:

  • Work:

    • id: string
    • title: string
    • description: string
    • hours: number
    • minionId: string
  • Routes required:

    • GET /api/minions/:minionId/work to get an array of all work for the specified minon.
    • POST /api/minions/:minionId/work to create a new work object and save it to the database.
    • PUT /api/minions/:minionId/work/:workId to update a single work by id.
    • DELETE /api/minions/:minionId/work/:workId to delete a single work by id.

Working with the 'Database'

Working with the 'Database'

Import and use helper functions for working with the database arrays on all routers:

  • getAllFromDatabase
  • getFromDatabaseById
  • addToDatabase
  • updateInstanceInDatabase
  • deleteFromDatabasebyId
  • deleteAllFromDatabase

Schemas

  • Minion:
    • id: string
    • name: string
    • title: string
    • salary: number
  • Idea
    • id: string
    • name: string
    • description: string
    • numWeeks: number
    • weeklyRevenue: number
  • Meeting
    • time: string
    • date: JS Date object
    • day: string
    • note: string

Take note that many values that could be numbers are in fact strings. Since we are writing an API, we can't trust that data is always provided by a client. You may need to transform between String and Number JavaScript types in order to provide full functionality in your API.

Set API Routes

API Routes

Routes Required

  • /api/minions

    • GET /api/minions to get an array of all minions.
    • POST /api/minions to create a new minion and save it to the database.
    • GET /api/minions/:minionId to get a single minion by id.
    • PUT /api/minions/:minionId to update a single minion by id.
    • DELETE /api/minions/:minionId to delete a single minion by id.
  • /api/ideas

    • GET /api/ideas to get an array of all ideas.
    • POST /api/ideas to create a new idea and save it to the database.
    • GET /api/ideas/:ideaId to get a single idea by id.
    • PUT /api/ideas/:ideaId to update a single idea by id.
    • DELETE /api/ideas/:ideaId to delete a single idea by id.
  • /api/meetings

    • GET /api/meetings to get an array of all meetings.
    • POST /api/meetings to create a new meeting and save it to the database.
    • DELETE /api/meetings to delete all meetings from the database.

For all /api/minions and /api/ideas routes, any POST or PUT requests will send their new/updated resources in the request body. POST request bodies will not have an id property, you will have to set it based on the next id in sequence.

For /api/meetings POST route, no request body is necessary, as meetings are generated automatically by the server upon request. Use the provided createMeeting function exported from db.js to create a new meeting object.

Set Server Boilerplate

Server Boilerplate

The server is missing key functionality to allow it to run. You must:

  • Set up body-parsing middleware with the body-parser packagae.
  • Set up CORS middleware with the cors package. You can use the default settings.
  • Mount the existing apiRouter at /api. This router will serve as the starting point for all your API routes.
  • Start the server listening on the provided PORT. Make sure to use the PORT constant and not a hard-coded number, as this is required for tests to run.

Take note of the comments in server.js, as your code needs to fit into specific places around the existing boilerplate.

Test

Run

  $ npm run test

to test:

  • API Routes
  • checkMillionDollarIdea middleware
  • Bonus

Custom Middleware

Custom Middleware

  • You will create a custom middleware function checkMillionDollarIdea that will come in handy in some /api/ideas routes. Write this function in the server/checkMillionDollarIdea.js file. This function will make sure that any new or updated ideas are still worth at least one million dollars! The total value of an idea is the product of its numWeeks and weeklyRevenue properties.

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.