@tayar/config v0.2.17-next
@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/configTo install the @next version of the package, use the following command:
npm install @tayar/config@nextFeatures
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();2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago