1.6.6 • Published 4 years ago

muxp v1.6.6

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

#Muxp

Fast and slick, no coding needed. Just launch and go.

###What is it? Muxp is simple node.js server used as an API endpoint(s) for testing purposes. ###When do I want to use it? When you are developing an application and your API is inaccessible for whatever reason, you can simply simulate its behavior with muxp. ###Tl;dr - how do I use it? 1. Install npm package

	npm install muxp --save
  1. Launch muxp

    Muxp is located in destination node_modules/muxp. Launch it simply by calling following command in muxp folder:

    node muxp.js [port]

    Example call:

    node muxp.js 3000

    This call will create API endpoints defined in heap.js on port 3000.

##heap.js Muxp is shipped with heap.js file. It is dataset file for every API endpoint with predefined structure, so you do not have to worry about creating it. Heap contains data to be sent by server after requesting it and rules for validating incomming data from request header/body. ###Heap anatomy

  1. Main wrapper

    'your/endpoint/:name': {
        
        method: 'POST',
    
        options: {},
    
        data: []
    }

    This is how you define endpoint in heap.js. How to use and fill the object keys can be found in steppes below. Note that you can also use variable parameters, using the leading ':' symbol.

  2. Method

    method: 'POST'

    Define method for endpoint. Able to accept multiple methods separated with '/' (eg. 'POST/PUT/GET').

  3. Options

    options: {
    
        validate: {
    
            header: {
                Authorization: '7x4egbc6s7fs2'    // If header of request payload contains 'Authorization' field, it has to have this value.
            },
    
            body: {
                code: '5e7fxE'    // Same as header, just for body payload.
            }         
        }
    }

    Simply enough, you can add key-value pairs into header and body objects. Incomming keys from header/body payload will be matched against the keys you created in heap as a form of validation. Failed validation results in status code 400 with descriptive message returned.

  4. Data

    data: [
    
        {
            field: 'Hello!'
        },
    
        {
            anotherField: {
                value: 'Hey!'
            }
        }
    ]

    Data array contains objects that can be sent back by API endpoint. User can browse through them by including 'dataIdx' field in the body of the request payload. dataIdx (with all other options) can either be placed directly in the body, or in special object called 'muxp-options' for better readability. Omitting dataIdx sets it automatically to 0.

####For POST request:

dataIdx: 0

######Placed directly in POST request body.

or

'muxp-options': {dataIdx: 2}

######Wrapped in muxp-options object, which is also placed directly in POST request body.

####For GET request:

http://localhost:3000/your/api/endpoint?dataIdx=3
1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

5 years ago

1.6.3

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.9

5 years ago

1.5.8

5 years ago

1.5.7

5 years ago

1.5.6

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago