# fi-consts

> Static database content manager for Mongoose

Latest version **1.0.1** (published 2017-01-03) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install fi-consts
pnpm add fi-consts
yarn add fi-consts
bun add fi-consts
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-01-03 |
| First published | 2016-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Final Development Studio |
| Maintainers | stgogm |
| Keywords | constants, constant, manager, statics, values, fi-seed |

## Links

- npm: https://www.npmjs.com/package/fi-consts
- Repository: https://github.com/finaldevstudio/fi-consts
- Homepage: https://github.com/finaldevstudio/fi-consts#readme
- Issues: https://github.com/finaldevstudio/fi-consts/issues
- npm.io page: https://npm.io/package/fi-consts

## Dependencies (3)

- [walk](https://npm.io/package/walk.md) ^2.3.9
- [fi-is](https://npm.io/package/fi-is.md) ^1.1.1
- [merge](https://npm.io/package/merge.md) ^1.2.0

## Recent versions

- 1.0.1 (latest) — 2017-01-03
- 1.0.0 — 2016-07-21

## README

# Fi Consts
Simple constant management for your application.

## Installing

```sh
npm install --save fi-consts
```

## Usage

```js
const CONSTS = require('fi-consts');
```

### Loading
You must first load your constants with a valid `config` object:

```js
consts CONSTS = require('fi-consts');

CONSTS.load(config);

// CONSTS now has your constants!

```

### Configuration
The configuration `Object` must have the `basedir` property defined as a valid path `String`. The `debug` parameter is optional.

- **basedir**: This is required and must be a `String`. This must be the absolute path to where the consts are located.
- **debug**: This option can be a `Function` to log with or a `Boolean`. If `true` it'll use `console.log`.

#### Example configuration

```js
{

  debug = require('debug')('app:statics'),

  basedir: path.join(__dirname, 'consts'),

}
```

### Getting values
Suppose we have this folder structure for the constants:

```
consts
├── other
│   ├── embedded
│   │   └── values.json
│   └── values.json
└── roles.json
```

Once loaded, this module will cache all your constants data into memory. To obtain a value just navigate the object. Keep in mind that all constant properties are defined in UPPER_CASE:

```js
console.log(CONSTS.ROLES.USER); // => { VALUE: 'value1234', SLUG: 'ROLE.USER' };
console.log(CONSTS.ROLES.USER.SLUG); // => 'ROLE.USER'
console.log(CONSTS.ROLES.OTHER.EMBEDDED.VALUES); // => { VALUE_1: {...}, VALUE_2: {...}}
```

---
_Source: https://npm.io/package/fi-consts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
