Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

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

Closed
stelioschar opened this issue Jul 19, 2017 · 3 comments
Closed

Comments

@stelioschar
Copy link

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
Copy link
Member

mischah commented Jul 19, 2017

Hej, this is something which:

  • is already on my imaginary feature list
  • I have a plan how to implement it
    • It will cause a breaking change

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 mischah changed the title How can add a simple text as response? Feat: Add support for plain text response as alternative to JSON Sep 12, 2017
mischah added a commit that referenced this issue Dec 3, 2017
The new option `mimeType` lets you respond with any file type you want.

Closes #7
@mischah
Copy link
Member

mischah commented Dec 5, 2017

Hej @stelioschar,

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

@stelioschar
Copy link
Author

🎉 🎉 🎉 🎉 🎉 🎉

mischah added a commit to micromata/generator-http-fake-backend that referenced this issue Feb 18, 2018
> # http-fake-backend 4.0.2
> 
> ## Bug Fixes
> 
> * update minimum node version in package.json
>
>*Change `engines.node` to `>=6.0.0` to reflect the minimum node version which is needed since http-fake-backend 4.0.0.*
>
> # http-fake-backend 4.0.1
>
> ## Bug Fixes
>
> * encoding of binary files send via endpoints
> 
> # http-fake-backend 4.0.0
> 
> ## Bug Fixes
> 
> * **dependencies:** Apply changes of boom update
> * **dependencies:** Update dependencies
> 
> ## Code Refactoring
> 
> * Refactor existing codebase
> 
> ## Documentation
> 
> * Update required minimum Node version in readme
> 
> ## Features
> 
> * Add support for other response content-types, closes [#7](micromata/http-fake-backend#7)
> * Add support for sending files as response, closes [#11](micromata/http-fake-backend#11)
>
> ## BREAKING CHANGES
>
> * The transitive dependency punycode@2.1.0 needs Node version ">=6".
> * The setup.js is divided to multiple files.
Therefore you need to change the import of the setup in your endpoint files
like the following:
> 
> ```javascript
> // before
> const SetupEndpoint = require('./setup/setup.js');
>
> // now
> const SetupEndpoint = require('./setup/index.js');
> 
> // or:
> const SetupEndpoint = require('./setup/');
> ```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants