micromata / http-fake-backend

Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
MIT License
311 stars 21 forks source link

Feat: Add support for plain text response as alternative to JSON #7

Closed stelioschar closed 6 years ago

stelioschar commented 7 years ago

Hey @mischah, Very promising work! I landed here once the json-server has some limitations.

What I would like to know is how can I return a simple text in some cases.

E.g When I make a PUT request to /api/simpleExample/update/1 to get the text DONE

module.exports = SetupEndpoint({
    name: 'simpleExample',
    urls: [{
        requests: [...]
    },
    {
        params: '/update/{id}',
        requests: [{
            method: ['PUT', 'PATCH'],
            response: 'DONE'
        }, {
            method: 'DELETE',
            response: 'DELETED'
        }]
    }]
});

Thank you

mischah commented 7 years ago

Hej, this is something which:

I wish I had more time, but I already spent my open source time slot for today otherwise I would start coding just now.

Long story short: I won’t promise anything, but it will be the next feature which land very soon.

Cheers, Michael

P.S. I wrote an article about the pros and cons compared to json-server which might be interesting: http://michael-kuehnel.de/api/2016/11/04/data-mocking-ways-to-fake-a-backend-api.html#pros-3

mischah commented 6 years ago

Hej @stelioschar,

it took a while … but the feature landed in v4.0.0 yesterday. See Changelog for a tiny migration guide.

stelioschar commented 6 years ago

πŸŽ‰ πŸŽ‰ πŸŽ‰ πŸŽ‰ πŸŽ‰ πŸŽ‰