Skip to content

Client Setup

import {
class DatabaseClient
DatabaseClient
} from "@vimn/webdb"
const
const Client: DatabaseClient
Client
= new
new DatabaseClient(config: ClientConfig): DatabaseClient
DatabaseClient
({
ClientConfig.auth: string

The authorization token

auth
:
const AUTH_KEY: string

This must be a unique secret string, use env variables

AUTH_KEY
,
ClientConfig.host: string

The URL of the database server

host
:
const HOST: string

This must be the url of your database, either the IP or the URL given by the host, try to add the protocol (http or https). Also avoid ending with /

HOST
,
ClientConfig.port: number

The port of the database server

port
: 80
});

The code you see here starts an instance of the client, which works to facilitate accesses, I will explain each part of the configuration below:

Explanation of the configuration

  1. Auth:

    This is the authentication key, it is used to verify that the request is valid and must be identical to the server.

  2. Host:

    This is the url to which the requests will be made, it must be complete, that is to say, it must include the protocol and the domain. Ex: http://localhost

  3. Port:

    This is the port to which the requests will be made.