@go-mailer/jarvis 3.3.0 → 4.0.1
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/index.js +13 -1
- package/lib/redis/index.js +32 -0
- package/lib/redis/schemas/Campaign.js +11 -0
- package/lib/redis/schemas/Contact.js +10 -0
- package/lib/redis/schemas/index.js +7 -0
- package/package.json +4 -2
package/index.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
const EnvVar = require('./lib/env')
|
|
2
2
|
const FeatureFlag = require('./lib/flag')
|
|
3
|
+
const Redis = require('./lib/redis/index')
|
|
3
4
|
const QueryBuilder = require('./lib/query')
|
|
4
5
|
const HTTP = require('./lib/middlewares/http')
|
|
5
6
|
const Authenticator = require('./lib/middlewares/auth')
|
|
6
7
|
const AutomationConstants = require('./lib/constants/automation')
|
|
7
8
|
const { RequestLogger, ProcessLogger } = require('./lib/middlewares/logger')
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
Authenticator,
|
|
12
|
+
AutomationConstants,
|
|
13
|
+
EnvVar,
|
|
14
|
+
FeatureFlag,
|
|
15
|
+
HTTP,
|
|
16
|
+
ProcessLogger,
|
|
17
|
+
RequestLogger,
|
|
18
|
+
QueryBuilder,
|
|
19
|
+
Redis
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { Client } = require('redis-om')
|
|
2
|
+
const Schemas = require('./schemas')
|
|
3
|
+
|
|
4
|
+
class RedisClient {
|
|
5
|
+
constructor () {
|
|
6
|
+
this.client = null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async connect (url = '') {
|
|
10
|
+
try {
|
|
11
|
+
this.client = await new Client().open(url)
|
|
12
|
+
console.log('Redis connection established')
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.log(`Redis connection: ${e.message}`)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get_client () {
|
|
19
|
+
return this.client
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
register_schema (schema = {}) {
|
|
23
|
+
const repo = this.client.fetchRepository(schema)
|
|
24
|
+
repo.createIndex()
|
|
25
|
+
return repo
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//
|
|
29
|
+
module.exports ={
|
|
30
|
+
RedisClient: new RedisClient(),
|
|
31
|
+
Schemas
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { Schema, Repository } = require('redis-om')
|
|
2
|
+
const client = require('../index')
|
|
3
|
+
|
|
4
|
+
const CampaignSchema = new Schema('campaign', {
|
|
5
|
+
id: {type: 'number'},
|
|
6
|
+
status: {type: 'number'}
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
CampaignRepo: new Repository(CampaignSchema, client)
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { Schema, Repository } = require('redis-om')
|
|
2
|
+
const client = require('../index')
|
|
3
|
+
|
|
4
|
+
const ContactImportSchema = new Schema('contactimport', {
|
|
5
|
+
data: { type: 'string' }
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
contactImportRepo: new Repository(ContactImportSchema, client)
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go-mailer/jarvis",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": "git@github.com:go-mailer-ltd/jarvis-node.git",
|
|
6
6
|
"author": "Nathan Oguntuberu <nateoguns.work@gmail.com>",
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"@logtail/node": "^0.3.3",
|
|
13
13
|
"axios": "^1.3.4",
|
|
14
14
|
"dotenv": "^16.0.3",
|
|
15
|
-
"jsonwebtoken": "^9.0.0"
|
|
15
|
+
"jsonwebtoken": "^9.0.0",
|
|
16
|
+
"redis": "^4.6.12",
|
|
17
|
+
"redis-om": "^0.4.3"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
18
20
|
"chai": "^4.3.7",
|