How to use @seagull/seed - 8 common examples

To help you get started, we’ve selected a few @seagull/seed examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seagull-js / seagull / packages / services-http / src / mode / seed.ts View on Github external
async fetch(url: string, init?: RequestInit): Promise {
    const seed = FixtureStorage.createByFetchParams>(url, init)
    const seedFixture = seed.get()

    if (seedFixture && !seed.expired) {
      // seed exists => return seed
      return createResponse(seedFixture)
    }

    const res = await fetch(url, init)

    let fixture: Fixture = {
      body: (await res.json()) || (await res.text()),
      options: {
        headers: res.headers,
        status: res.status,
        statusText: res.statusText,
      },
github seagull-js / seagull / packages / services-http / src / mode / seed.ts View on Github external
async fetch(url: string, init?: RequestInit): Promise {
    const seed = FixtureStorage.createByUrl>(
      url,
      init,
      this.testScope
    )

    try {
      const seedFixture = seed.get()
      if (!seed.expired) {
        // seed exists => return seed
        return createResponse(seedFixture)
      }
    } catch {
      // ignore
    }
    const fixture = await this.fetchFixture(url, init)
    seed.set(fixture)
github seagull-js / seagull / packages / services-http / src / mode / pure.ts View on Github external
async fetch(url: string, init?: RequestInit): Promise {
    const seed = FixtureStorage.createByFetchParams>(url, init)
    const fixture = seed.get()
    return createResponse(fixture)
  }
}
github seagull-js / seagull / packages / services-http / src / mode / pure.ts View on Github external
async fetch(url: string, init?: RequestInit): Promise {
    const seed = FixtureStorage.createByFetchParams>(url, init)
    const fixture = seed.get()
    if (!fixture) {
      throw new Error('Http: fixture (seed) is missing.')
    }
    if (seed.expired) {
      throw new Error('Http: fixture (seed) is expired.')
    }
    return createResponse(fixture)
  }
}
github seagull-js / seagull / packages / services-soap / src / mode / seed.ts View on Github external
const seedify = async (fnc: ClientFunction, name: string, args: any) => {
      const seed = FxSt.createByUrl(
        `${endpoint}/${name}`,
        args,
        this.testScope
      )
      try {
        try {
          if (seed.expired) {
            throw new Error()
          }
          const response = seed.get()
          handleSeedError(response)
          return response
        } catch {
          const response = await fnc(args)
          seed.set(response)
          return response
github seagull-js / seagull / packages / services-soap / src / mode / pure.ts View on Github external
const purify = async (fnc: ClientFunction, name: string, args: any) => {
      const seed = FixtureStorage.createByUrl(
        `${endpoint}/${name}`,
        args,
        this.testScope
      )
      const response = seed.get()
      handleSeedError(response)
      return response
    }
github seagull-js / seagull / packages / services-soap / src / mode / seed.ts View on Github external
async getClient(opts: ClientOptions): Promise {
    try {
      const wsdl = await this.fetchWsdl(opts)
      const endpoint = getEndpoint(opts)
      if (!wsdlIsFile(opts)) {
        const seed = FxSt.createByWsdlUrl(endpoint)
        try {
          seed.get()
          if (seed.expired) {
            throw new Error()
          }
        } catch {
          seed.set(wsdl)
        }
      }
      const client = await getClientInternal(opts)
      const seedClient = await this.seedifyClient(client, endpoint)
      return seedClient
    } catch (e) {
      throw new SoapError(
        `Unable to create the SOAP seed mode client: ${e.message}`,
        e
github seagull-js / seagull / packages / services-soap / src / mode / pure.ts View on Github external
async getClient(opts: ClientOptions): Promise {
    const endpoint = getEndpoint(opts)
    const wsdlPath = `seed/${endpoint}.wsdl`.replace('://', '/')
    const options = { endpoint, wsdlPath, credentials: opts.credentials }
    try {
      const client = await getClientInternal(options)
      const pureClient = await this.purifyClient(client, endpoint)
      return pureClient
    } catch (e) {
      if (e.code === 'ENOENT') {
        throw new SeedError(`Fixture (seed) WSDL is missing: ${wsdlPath}`, e)
      }
      throw new SoapError(`Unable to create pure mode client: ${e.message}`, e)
    }
  }

@seagull/seed

Seed implementation for the seagull framework

LGPL-3.0
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis