@go-mailer/jarvis 3.3.0 → 4.0.0
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 +12 -0
- package/lib/redis/schemas/Contact.js +11 -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,12 @@
|
|
|
1
|
+
const { Schema, Entity } = require('redis-om')
|
|
2
|
+
const client = require('../index')
|
|
3
|
+
|
|
4
|
+
class Campaign extends Entity {}
|
|
5
|
+
const CampaignSchema = new Schema(Campaign, {
|
|
6
|
+
id: {type: 'number'},
|
|
7
|
+
status: {type: 'number'}
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
CampaignRepo: client.register_schema(CampaignSchema)
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { Schema, Entity } = require('redis-om')
|
|
2
|
+
const client = require('../index')
|
|
3
|
+
|
|
4
|
+
class ContactImport extends Entity {}
|
|
5
|
+
const ContactImportSchema = new Schema(ContactImport, {
|
|
6
|
+
data: { type: 'string' }
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
contactImportRepo: client.register_schema(ContactImportSchema)
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go-mailer/jarvis",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
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",
|