Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qiwi/cookiemonster
Stateless fake API based on cookie processing
https://github.com/qiwi/cookiemonster
Last synced: 4 days 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 (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-03-28T23:48:04.000Z (8 months ago)
- Last Synced: 2024-10-31T15:41:20.489Z (15 days 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
[![CI](https://github.com/qiwi/cookiemonster/actions/workflows/ci.yaml/badge.svg?branch=master&event=push)](https://github.com/qiwi/cookiemonster/actions/workflows/ci.yaml)
[![Maintainability](https://api.codeclimate.com/v1/badges/01b67bf5bc60a67df296/maintainability)](https://codeclimate.com/github/qiwi/cookiemonster/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/01b67bf5bc60a67df296/test_coverage)](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)