hawkwhisper v1.0.7
Please report any bugs to WilliamCRamsey1990@gmail.com
1.0.7: Small patch. getItem's callback data will now return 'false' if item is not found. This was crucial but I overlooked it. Fixed now, though.
1.0.6: A tweak to the clone system. The setClone function is removed while you would now use an array. See example. This lets you create unlimited backups in any location(s) you want.
FEATURES Encryption (use Crypto combined with the encryption default for increased security) Simple read/write database system; resource light. Scalable
Simple Database This package lets you create a very lightweight database system using JSON. To make a long story short, it creates a folder with the name of your specified database at the path you set. Here's an example
const hawk=require('hawkwhisper');
const os=require('os');
/* Set a custom encryption algorithm
main.encrypt_algorithm = (args, callback) => {
args[0] will be JSON DATA
args[1] will be the key you set
callback(encrypted_str);
The callback() function MUST return the encrypted string.
Please report any bugs to WilliamCRamsey1990@gmail.com
}
main.decrypt_algorithm = (args, callback) => {
args[0] will be the key you set
args[1] will be the encrypted string you're decrypting.
callback(decrypted_str);
The callback() function MUST return a decrypted string that
can be parsed into JSON data using JSON.parse().
}
data and key must be set. data is JSON format and
key is the key used for encryption.
*/
let main = new hawk.base('hawk', [
`${os.homedir()}/.hawk`,
`${os.homedir()}/.hawk_backup1`,
`${os.homedir()}/.hawk_backup2`
], () => {
console.log('database Created');
main.newTable('sample', (err, path) => {
main.newItem('sample', 'user', 'secret', {data:256}, (err, path) => {
main.getItem('sample', 'user', 'secret', (data) => {console.log(data);});
})
});
});
This will create a database called 'hawk' in your user's home directory inside of a folder called '.hawk'
Properties
- require: const hawk=require('hawkwhisper');
create database: let item = new hawk.base(database_name, directory1, directory2 ..., callback() => {})
- Creates a new database.
create table: item.newTable('users', (err, path) => {})
- Creates a table for the database.
create item: item.newItem('users', 'sample_user', 'secret_key', JSON_Data, (err, path) => {})
- Creates an item for a table inside the database.
get item: item.getItem('users', 'sample_user', 'secret_key', (data) => {})
Gets data from an item inside of a table. If secret_key is incorrect, data will be returned as 'DECRYPT ERROR', else it'll return JSON data.
view tables: item.viewTables();
- Returns tables for database
view items: item.viewItems('users');
- Returns a list of all items of a table.