Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abumq/residue-node
Official Node.js client library to interact with residue logging server seamlessly. This is built using Node.js built-in modules (net, crypto).
https://github.com/abumq/residue-node
logging-library nodejs nodejs-library remote-logging residue residue-client residue-tools
Last synced: about 1 month ago
JSON representation
Official Node.js client library to interact with residue logging server seamlessly. This is built using Node.js built-in modules (net, crypto).
- Host: GitHub
- URL: https://github.com/abumq/residue-node
- Owner: abumq
- License: other
- Created: 2017-04-04T04:16:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-03T07:56:34.000Z (over 1 year ago)
- Last Synced: 2024-12-01T22:38:35.983Z (about 1 month ago)
- Topics: logging-library, nodejs, nodejs-library, remote-logging, residue, residue-client, residue-tools
- Language: JavaScript
- Homepage:
- Size: 826 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
﷽
Residue Node.js Client
Secure Node.js library to interact with residue server seamlessly.
This module provides interface for connecting and interacting with residue server seamlessly, means, once you are connected this module takes care of expired tokens and clients and keep itself updated with latest tokens and ping server when needed to stay alive.
## API
#### `connect(options)`
Connects application to residue using params. If options is not specified, you should use `loadConfiguration` to load the optionsValid options are:
```
{
url: ":",
application_id: ,
rsa_key_size: ,
utc_time: ,
time_offset: ,
client_id: ,
client_private_key: [must be provided with client_id],
client_public_key: [must be provided with client_id],
client_key_secret: ,
server_public_key:
}
```Please refer to [`loadConfiguration`](https://abumq.github.io/residue/docs/class_residue.html#a8292657c93a775b6cbf22c6d4f1166f4) in our C++ library's documentation for more details.
#### `loadConfiguration(jsonFilename)`
Loads configurations / options via json file. Returns true if successfully loaded, otherwise false.This does not verify the options. Options are validated in `connect()` function
#### `getLogger(logger_id)`
Returns logger class for logging interface## Usage
```js
const ResidueClient = require('residue');const residue = new ResidueClient();
const logger = residue.getLogger('sample-app');
const confFile = 'client.conf.json';
if (residue.loadConfiguration(confFile)) {
residue.connect();
}// or
// residue.loadConfiguration({ url: ... })
// or
// residue.loadConfiguration('{ url: ... }')// ALTERNATIVELY
residue.connect({
url: ...
});logger.info('simple log');
logger.info('array %s', [1, 2, 3]);
var person = { 'name': 'Adam', 'age': 960, }
logger.info('obj %s', person);logger.info('null %s', null);
logger.info('undefined %s', undefined);
```
## Log
```js
logger.info(...);
logger.warn(...);
logger.error(...);
logger.debug(...);
logger.trace(...);
logger.fatal(...);
logger.verbose(verbose_level, ...);
```## Native Binding
Residue Node.js also comes with native binding that uses [C++ client library](https://github.com/abumq/residue-cpp) to manage connections and asyncronous requests.If you have installed [`residue-native`](https://www.npmjs.com/package/residue-native) package alongside `residue`, native binding will be used otherwise it will fallback to JS implementation.
## Sample
You can check out [sample client apps](https://github.com/abumq/residue-node/blob/master/samples) for practical use of this package.## License
```
Copyright 2017-present @abumq (Majid Q.)Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```