https://github.com/qiwi/cookiemonster
Stateless fake API based on cookie processing
https://github.com/qiwi/cookiemonster
Last synced: 2 months ago
JSON representation
Stateless fake API based on cookie processing
- Host: GitHub
- URL: https://github.com/qiwi/cookiemonster
- Owner: qiwi
- License: mit
- Created: 2023-04-11T12:32:43.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-28T23:48:04.000Z (about 1 year ago)
- Last Synced: 2025-02-15T22:35:39.369Z (3 months ago)
- Language: TypeScript
- Size: 266 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# qookiemonster
[](https://github.com/qiwi/cookiemonster/actions/workflows/ci.yaml)
[](https://codeclimate.com/github/qiwi/cookiemonster/maintainability)
[](https://codeclimate.com/github/qiwi/cookiemonster/test_coverage)
> Stateless fake API based on cookie processing
## Usage
On server side:
```ts
//...
import {cookiemonster} from '@qiwi/cookiemonster'const app = express()
app.use(cookieParser())
app.use(bodyParser.json())
app.use(cookiemonster())app.listen(8080)
```On client:
```ts
import {formatScenario} from '@qiwi/cookiemonster'const data = formatScenario({
steps: [
{res: {code: 200, body: {foo: 'bar'}}}
]
})document.cookie = `Cookiemonster=${data}`
const result = await fetch('http://localhost:8080', {credentials: 'include'})
const json = await result.json() // {foo: 'bar'}
```## Refs
* [mock-server/mockserver](https://github.com/mock-server/mockserver)## License
[MIT](./LICENSE)