Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify interface for initialization #7

@CaptainCodeman

Description

@CaptainCodeman

Combine Handler into KeyManager, and also pass in KeyExtractor Options as a parameter instead of it being a separate instance. i.e. it's just the key store and token bucket implementation (that have different implementations) that need to be passed in.

before

const store = new InMemoryKeyStore()
const manager = new KeyManager(store)
const bucket = new InMemoryTokenBucket()
const extractor = new KeyExtractor({ searchParam: 'key', httpHeader: 'x-api-key' })
const handler = new Handler(extractor, manager, bucket)

export const handle = handler.handle

after

const store = new InMemoryKeyStore()
const bucket = new InMemoryTokenBucket()
const manager = new KeyManager(store, bucket, { searchParam: 'key', httpHeader: 'x-api-key' })

export const handle = manager.handle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions