thermo-core v1.2.1
Thermo-Core
This is a small set of core libraries used by various thermo modules. Add this to your thermo project using
npm install --save thermo-core
Libraries
properties-manager
file - Defines the properties file to be loaded (defaults to project.properties)
encryptor - Defines the encryptor to use when encrypting property values
create(sections, encryptor, quietly) - Creates a new properties file
sections - A hash of properties where each property has a name, description and default
quietly - Normally this method asks for user input, quietly assumes all default values are to be usedload() - Loads properties (from file or cache)
logging-manager
properties - Defines the properties for the logger
debug(arguments) - Logs a debug message to stdout if the logging level is set to debug
info(arguments) - Logs an info message to stdout if the logging level is set to debug/info
warn(arguments) - Logs a warning message to stdout if the logging level is set to debug/info/warn
error(arguments) - Logs an error message to stderr if the logging level is set to debug/info/warn/error
fatal(arguments) - Logs a fatal message to stderr always
Properties
disabled - A truthy to indicate if the logger is disabled
timestamp - The moment() timestamp to use for log messages (default: DD-MMM-YY hh:mm:ss:SSS)
level - The logging level (debug, info, warn, error, fatal; default: error)
encryption-manager
properties - Defines the properties for the encryptor
encrypt(secret) - Encrypts a string
decrypt(cipher) - Decrypts a string
Properties
salt - The salt to use for encryption (default: random uuid)
mongodb-manager
properties - Defines the properties for the connection
encryptor - Defines the encryptor to use when decrypting the connection password
status - Returns the current status (Connected or Not Connected)
getConnectionString() - Gets the current mongodb:// connection string
connect() - Connects to a mongo instance
disconnect() - Disconnects a mongo instance
drop() - Drops the current schema
Properties
host - The host where mongo is running (default: localhost)
port - The port where mongo is listening (default: 27017)
schema - The schema to connect to
poolsize - The size of the connection pool (default: 5)
user - The mongo user name
password - The mongo user password
express-manager
properties - Defines the properties for the instance
status - Returns the current status (Running or Not Running)
register(path, router) - Registers a new route path - The path where to mount router - The express router or callback function
start() - Starts a new express instance and bind all routes
stop() - Stops the express instance
Properties
host - The host interface where express will bind to (default: localhost)
port - The port where express will bind to (default: 7500)
postgres-manager
properties - Defines the properties for the connection
encryptor - Defines the encryptor to use when decrypting the connection password
status - Returns the current status (Connected or Not Connected)
getConnectionString() - Gets the current postgres:// connection string
getClient(db) - Gets a client from the connection pool.
db - The name of the database to connect tocreate(db) - Creates a new database.
db - The name of the database to createdrop(db) - Drops the given database.
db - The name of the database to createProperties
host - The host where postgres is running (default: localhost)
port - The port where postgres is listening (default: 5432)
database - The database to connect to
user - The postgres user name
password - The postgres user password