Code Monkey home page Code Monkey logo

example-api-express-typescript's Introduction

Example API for HackYourFuture Angular class

To start the app, first cd to the folder where this readme is located. Then:

npm install -g gulp
npm install
gulp
node dist/server.js

This should result in something like:

Users API listening on port 3000

!KEEP THIS TAB OPEN! it will wait for your requests

In your browser, go to http://localhost:3000

This should show a friendly message :).

Other methods, like POST and PATCH and DELETE can only be made from either Postman or from your Angular application.

Possible requests and example response

Response body:

GET / -

Response - 200 - Body: {"message": "Users API up and running!"}

GET /v1/users

Response - 200 - Body:

[
  {
    "firstName": "Piet",
    "lastName": "Friet",
    "age": 72,
    "email": "[email protected]",
    "profilePictureUrl": "http://retailparkroermond.com/nl/horeca/piet-friet/afbeeldingen/piet-friet-l.png",
    "_id": "8m0nGYgSttzCNG0t"
  }
]

POST /v1/users

Request body:

{
  "firstName": "Piet",
  "lastName": "Friet",
  "age": 72,
  "email": "[email protected]",
  "profilePictureUrl": "http://retailparkroermond.com/nl/horeca/piet-friet/afbeeldingen/piet-friet-l.png"
}

Response body:

{
  "firstName": "Piet",
  "lastName": "Friet",
  "age": 72,
  "email": "[email protected]",
  "profilePictureUrl": "http://retailparkroermond.com/nl/horeca/piet-friet/afbeeldingen/piet-friet-l.png",
  "_id": "B1w2s30z2L3n0Jrj"
}

PATCH /v1/users/B1w2s30z2L3n0Jrj

Request body:

{
  "firstName": "NewFirstName"
}

Response (if user exists in database) - 204 - Body:

(empty)

Response (if user does not exist in database) - 404 - Body:

{"Reason": "That user does not exist"}

DELETE /v1/users/B1w2s30z2L3n0Jrj

Request body:

{
  "firstName": "NewFirstName"
}

Response (if user exists in database) - 204 - Body:

(empty)

Response (if user does not exist in database) - 404 - Body:

{"Reason": "That user does not exist"}

example-api-express-typescript's People

Contributors

daanaerts avatar

Watchers

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