GithubHelp home page GithubHelp logo

express-app's Introduction

Express Aapp

Rest API

My Task

Rest API example to practice

Create a Express server that handles:

  • A GET request endpoint at / as a landing page for your API.
  • A GET request endpoint at /user to display all users in DB.
  • A POST request endpoint at /user to add new user to DB.
  • A PUT request endpoint at /user/:name to update user from DB upon their name.
  • A PATCH request endpoint at /user/:name to update some user data from DB upon their name.
  • A GET request endpoint at /display/:name to display one user from DB upon their name.

New user endpoint should be able to accept a JSON object like the following:

{
  "userName": "steel",
  "userPass": "123pass",
  "age": "32",
  "fbw": "48",
  "toolStack": ["Js", "Html5", "Css3", "Sass"],
  "email": "[email protected]"
}

For the endpoint /user that adds new user

  • Create a middleware method that will make sure the object received contains userName, userPass, age, fbw and email.
  • Create a middleware method that will check if the user is above 18 years old
  • Create a middleware method that will check if the user belongs to our FBW
  • If all the above is true, then you should send a response with a success message
  • If any of the middleware fails, you should send a response with an error message that says why the user is not valid.

EXAMPLE RESPONSES

// Success case
{
  "message" : "This user is valid!"
}


// Failure
{
  "message": "We can not validate your user. They are not a member of FBW48"
}


// Other case of Failure
{
  "message": "We can not validate your user. we don't accept pp that are below 18 years of age"
}

For the /display/:name endpoint:

  • Create a middleware that makes the firstName starts with a capital letter.
  • Create a middleware that sorts the toolStack array alphabetically.
  • Create a middleware that will turn age and fbw to numbers.

EXAMPLE RESPONSES

{
  "userName": "Steel",
  "userPass": "123pass",
  "age": 32,
  "fbw": 48,
  "toolStack": ["Css3", "Html5", "Js", "Sass"],
  "email": "[email protected]"
}

Make sure that you Organize (route, controller and module) Ps: new our new Rest API needs new DB ๐Ÿ˜‰

Happy codding โ˜˜๏ธ

express-app's People

Contributors

iuliansta 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.