0.2.14-next • Published 2 years ago

@tayar/config v0.2.14-next

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@tayar/config

This package provides a configuration setup for your application, including database connection and token secrets management.

Installation

To install the package, use the following command:

npm install @tayar/config

To install the @next version of the package, use the following command:

npm install @tayar/config@next

Features

The @tayar/config package provides the following features:

  • Initialization : Sets up the configuration for your application, including database connection and token secrets.

  • getConfig : Retrieves the current configuration.

Usage

  • Import the init and getConfig functions from the package and use them in your application (Backend ):
import { init, getConfig } from "@tayar/config";

Initialization The init function takes the following parameters:

  • url: The connection string for your database.
  • secrets: An object containing the accessToken, refreshToken, and resendToken secrets.
  • mongooseInstance: The mongoose instance to use for connecting to the database.
  • cookieOptions: An array of cookie options. Here's an example of how to use it:
await init(
    "mongodb://localhost:27017/mydb",
    {
        accessToken: "youraccesstokensecret",
        refreshToken: "yourrefreshtokensecret",
        resendToken: "yourresendtokensecret"
    },
    mongoose,
    [{ name: "cookie1", options: {} }, { name: "cookie2", options: {} }]
);

Get Config

The getConfig function retrieves the current configuration. It throws an error if the configuration has not been initialized.

Here's an example of how to use it:

const config = getConfig();
0.2.24-next

2 years ago

0.2.22-next

2 years ago

0.2.23-next

2 years ago

0.2.21-next

2 years ago

0.2.16-next

2 years ago

0.2.18-next

2 years ago

0.2.13-next

2 years ago

0.2.20-next

2 years ago

0.2.12-next

2 years ago

0.2.15-next

2 years ago

0.2.19-next

2 years ago

0.2.13

2 years ago

0.2.11-next

2 years ago

0.2.17-next

2 years ago

0.2.14-next

2 years ago

0.2.7-next

2 years ago

0.2.10-next

2 years ago

0.2.9-next

2 years ago

0.2.8-next

2 years ago

0.2.1-next

2 years ago

0.2.6-next

2 years ago

0.2.3-next

2 years ago

0.2.4-next

2 years ago

0.2.5-next

2 years ago

0.2.2-next

2 years ago

0.1.9-next

2 years ago

0.2.0-next

2 years ago

0.1.8-next

2 years ago

0.1.7-next

2 years ago

0.1.5-next

2 years ago

0.1.3-beta

2 years ago

0.1.2-next

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago