This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createEnum(arr) { | |
| const obj = arr.reduce((accum, item, index) => { | |
| index = index.toString(); | |
| accum[index] = item; | |
| accum[item] = index; | |
| return accum; | |
| }, {}); | |
| Object.defineProperties(obj, { | |
| names: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const AuditLog = auditLogDb.define('audit-log', { | |
| userId: { | |
| type: Sequelize.DataTypes.INTEGER, | |
| allowNull: true, | |
| }, | |
| actionType: { | |
| type: Sequelize.DataTypes.STRING, | |
| allowNull: false, | |
| }, | |
| table: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function promiseTimeout(promise, ms){ | |
| let timerId; | |
| let timeout = new Promise((resolve, reject) => { | |
| timerId = setTimeout(() => reject('timeout'), ms); | |
| }); | |
| return Promise.race([ | |
| timeout, | |
| promise.then(r => { | |
| clearTimeout(timerId); |