README
smart-common-lib
1. Need environment variable
1. database
need mariadb environment variable
- DB_HOST
- DB_PORT
- DB_USERNAME
- DB_PASSWORD
- DB_NAME
- DB_CONNECTION_LIMIT
2. kafka
need kafka log collector environment variable
- KAFKA_LOG_TOPIC_ID
- KAFKA_CLIENT_ID
- KAFKA_BROKER_URL
3. session-manager-url
need session manager url variable
- SESSION_MANAGER_URL
2. Export module
1. database
using mariadb lib.
- getPool: (trackingId)
- getConn: (trackingId)
- selectList: (sql, param, trackingId)
- selectOne: (sql, param, trackingId)
- insert: (sql, param, trackingId)
- update: (sql, param, trackingId)
- delete: (sql, param, trackingId)
2. transaction
using mariadb transaction lib.
- execTransactionQuerys: (queryInfos, trackingId)
3. crypto
using chiper lib.
- encrypt: (toEncryptText)
- decrypt: (encryptionText)
4. middleware
get session lib
- session: (req, res, next)
5. response
using express response lib.
- authErrorResp: (errorData, response, trackingId)
- notFoundErrorResp: (errorData, response, trackingId)
- errorResp: (errorData, response, trackingId)
- successResp: (responseData, response, trackingId)
- successRespFile: (fileNm, filePath, response, trackingId)
6. util
using express util lib.
- getTrackingId: (request)
2. Class
1. Redis
using redis lib. class
- constructor(config)
- putHash(key, tx)
- getHash(key)
- getFields(key, ...fields)
- getList(key)
- push(key, value)
- shift(key, value)
- put(key, value)
- get(key)
- del(key)
- sadd(key, value)
- srem(key, value)
- sismember(key, value)
- exists(key)
- close()
2. Kafka
using kafka lib. class
- constructor(kafkaClientId, brokerUrl)
- kafkaConsumer(topicId, messageProcessCallbackFunction)
- kafkaProducer(topicId, message)
3. LocalLogger
using local logger lib. class
- constructor(srcPath, saveLogFileName = undefined)
- info(msg, trackingId = undefined)
- debug(msg, trackingId = undefined)
- error(msg, err = undefined, trackingId = undefined)
- warn(msg, trackingId = undefined)
4. RecvLogger
using receive logger lib. class (only log-writer)
- constructor(saveLogFileName)
- info(msg)
- debug(msg)
- error(msg)
- warn(msg)
5. SendLogger
using send logger lib. class (send to log-writer by kafka)
- constructor( srcPath, kafkaTopicId = process.env.KAFKA_LOG_TOPIC_ID, kafkaClientId = process.env.KAFKA_CLIENT_ID, kafkaBrokerUrl = process.env.KAFKA_BROKER_URL, )
- async _sendLogMsg(topicId, message)
- info(msg, trackingId = undefined)
- debug(msg, trackingId = undefined)
- error(msg, err = undefined, trackingId = undefined)
- warn(msg, trackingId = undefined)