Class VantAPI

Hierarchy

Properties

app: Express
closed: boolean = false
keys: {
    admin: undefined | string;
    read: undefined | string;
    readwrite: undefined | string;
    write: undefined | string;
} = {}

Holds the four base api keys which are generated while configuring the vant api for the first time.

Type declaration

  • admin: undefined | string
  • read: undefined | string
  • readwrite: undefined | string
  • write: undefined | string
log: Logger
server?: DestroyableServer<Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>>
settings: APISettings

The api's settings. Change these by using VantAPI.configure.

Methods

  • Type Parameters

    Parameters

    Returns VantAPI

  • Stops the http server and closes the connection to the database. This action is final!

    Returns Promise<void>

  • Configures the vant api. You can setup the default units, the used port and the logging behaviour. Pass { useEnvironmentVariables: true } to setup these settings using environment variables (e.g. stored in a .env file).

    Parameters

    Returns Promise<void>

  • Type Parameters

    Parameters

    • event: E
    • Rest ...args: Parameters<APIEvents[E]>

    Returns boolean

  • Returns (string | symbol)[]

  • Generates a new api key for your api with the passed role. Once the key has been stored in the database the promise resolves and the uuidv4 key is returned as string.

    Role explanations

    • "read": One can use read routes only (requesting any kind of weather data)
    • "write": One can use write routes only (uploading new weather data using post requests)
    • "readwrite": Once can use all write and read routes.
    • "admin": One can use all write / read routes and generate new api keys.

    Parameters

    Returns Promise<string>

    the uuidv4 api key as string

  • Returns number

  • Type Parameters

    Parameters

    • event: E

    Returns number

  • Type Parameters

    Parameters

    • event: E

    Returns APIEvents[E][]

  • Type Parameters

    Parameters

    Returns VantAPI

  • Type Parameters

    Parameters

    Returns VantAPI

  • Type Parameters

    Parameters

    Returns VantAPI

  • Type Parameters

    Parameters

    Returns VantAPI

  • Type Parameters

    Parameters

    Returns VantAPI

  • Type Parameters

    Parameters

    • event: E

    Returns APIEvents[E][]

  • Type Parameters

    Parameters

    • Optional event: E

    Returns VantAPI

  • Type Parameters

    Parameters

    Returns VantAPI

  • Parameters

    • maxListeners: number

    Returns VantAPI

  • Starts the http server on the configured port. The promise resolves when the server starts listening for incoming requests.

    Returns Promise<void>

  • Stops the http server. If the server hasn't been started yet no error will occur (but a warning will be logged).

    Returns Promise<void>

Generated using TypeDoc