GithubHelp home page GithubHelp logo

elevator's Introduction

Simplified Elevators API

Krzysztof Plesniak

2 komendy i projekt startuje
npm install dla React
npm run dev

Starting server:

npm install
npm start

Getting building shape:

$ http --json :8080/building

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 27
Content-Type: application/json; charset=utf-8
Date: Thu, 16 Apr 2020 12:59:43 GMT
ETag: W/"1b-RMyPK0V5hMkIorEezvhNgQVdu48"
X-Powered-By: Express

{
    "elevators": 3,
    "floors": 10
}

Getting snapshot of elevator states:

$ http --json --stream :8080/elevators

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 127
Content-Type: application/json; charset=utf-8
Date: Thu, 16 Apr 2020 12:58:09 GMT
ETag: W/"7f-TCE7+HtB6hHtke6eR579S4aKFMQ"
X-Powered-By: Express

[
    {
        "floor": 0,
        "id": "elv0",
        "state": "stopped"
    },
    {
        "floor": 0,
        "id": "elv1",
        "state": "stopped"
    },
    {
        "floor": 0,
        "id": "elv2",
        "state": "stopped"
    }
]

Event stream (SSE):

$ http --json --stream :8080/stream

HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Type: text/event-stream
Date: Thu, 16 Apr 2020 12:53:07 GMT
Transfer-Encoding: chunked
X-Accel-Buffering: no
X-Powered-By: Express

id: 0
data: {"id":"elv0","floor":1,"state":"up","targetFloor":2}

id: 1
data: {"id":"elv0","floor":2,"state":"up","targetFloor":2}

id: 2
data: {"id":"elv0","floor":2,"state":"stopped"}

Calling elevator to a floor:

$ http --json PUT :8080/floor/2

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 70
Content-Type: application/json; charset=utf-8
Date: Thu, 16 Apr 2020 12:48:23 GMT
ETag: W/"46-b/WkupWesCsDfHmCwRgMHuvi+UU"
X-Powered-By: Express

{
    "elevator": {
        "floor": 0,
        "id": "elv0",
        "state": "stopped",
        "targetFloor": 2
    }
}

elevator's People

Contributors

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