corebasic 1.0.42 → 1.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/auth.js +2 -2
- package/libs/features.js +1 -1
- package/libs/utils.js +5 -4
- package/package.json +2 -1
package/libs/auth.js
CHANGED
|
@@ -57,8 +57,8 @@ async function attemptLogin(req, res) {
|
|
|
57
57
|
let userId = req.body.userId ?? Utils.uid()
|
|
58
58
|
let now = Utils.now().toISOString()
|
|
59
59
|
let data = req.body.data ?? {}
|
|
60
|
-
let meta = { clientId,
|
|
61
|
-
await Elabase.update(collection, { _id: phone }, { $set: { otp, clientId, time,
|
|
60
|
+
let meta = { clientId, created: now, updated: now, ...data}
|
|
61
|
+
await Elabase.update(collection, { _id: phone }, { $set: { otp, clientId, time, updated: now }, $setOnInsert: { _id: phone, otp, time, userId, ...meta } }, { upsert: true })
|
|
62
62
|
return {mode: 'login', success: true, userId, expiry, phone}
|
|
63
63
|
}
|
|
64
64
|
throw {...errMessage, mode: 'login', info: 'Generating Info Failed'}
|
package/libs/features.js
CHANGED
|
@@ -87,7 +87,7 @@ const commandAction = async (req, res, feature, featureName) => {
|
|
|
87
87
|
let txn = req.body.txn ?? Util.uid()
|
|
88
88
|
req.body.data._id = req.body.data._id ?? txn
|
|
89
89
|
try {
|
|
90
|
-
await Kafka.send(`features.${feature.topic}`, { data: req.body.data, feature: featureName, txn, id: _id }, _id)
|
|
90
|
+
await Kafka.send(`features.${feature.topic}`, { data: req.body.data, feature: featureName, txn, id: _id, date: new Date().getTime() }, _id)
|
|
91
91
|
|
|
92
92
|
} catch {
|
|
93
93
|
throw {status: 500, message: "Failed to queue the transaction"}
|
package/libs/utils.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as ObjectId from './ObjectId.js'
|
|
2
|
+
import {readFile} from 'fs/promises';
|
|
3
|
+
import 'jsonminify'
|
|
2
4
|
|
|
3
5
|
export let pipeline = { execute: execute }
|
|
4
6
|
|
|
@@ -141,10 +143,9 @@ export function sum(array) { // Eg: sum([10,20,undefined, NaN, 40])
|
|
|
141
143
|
// ----------------
|
|
142
144
|
// JSON
|
|
143
145
|
// ----------------
|
|
144
|
-
export async function fileToJson(
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
return require(url.replace('file://',''));
|
|
146
|
+
export async function fileToJson(path, file) {
|
|
147
|
+
let data = (await readFile(new URL(file, path).toString().replace('file://',''), 'utf8'))
|
|
148
|
+
return JSON.parse(JSON.minify(data))
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
// ----------------
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corebasic",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.43",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"axios": "^1.4.0",
|
|
14
|
+
"jsonminify": "^0.4.2",
|
|
14
15
|
"jsonwebtoken": "^9.0.1",
|
|
15
16
|
"otp-generator": "^4.0.1"
|
|
16
17
|
}
|