JSPM

@averspec/protocol-http

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 25
  • Score
    100M100P100Q75177F
  • License MIT

HTTP protocol for Aver acceptance testing

Package Exports

  • @averspec/protocol-http

Readme

@averspec/protocol-http

Status: Early release. API is stabilizing. Breaking changes will be noted in release notes.

HTTP protocol for Aver acceptance testing. Provides a fetch-based HTTP client as the adapter context.

Install

npm install @averspec/protocol-http

Usage

import { adapt } from '@averspec/core'
import { http } from '@averspec/protocol-http'
import { cart } from './domains/cart'

export const httpAdapter = adapt(cart, {
  protocol: http({ baseUrl: 'http://localhost:3000' }),
  actions: {
    addItem: async (ctx, { name }) => {
      await ctx.post('/cart/items', { name })
    },
  },
  queries: {
    cartTotal: async (ctx) => {
      const res = await ctx.get('/cart/total')
      return res.json()
    },
  },
})

The http() protocol provides get, post, put, patch, and delete methods on the context, all pre-configured with the base URL.

License

MIT