create-dacosta-proj 1.0.8 → 1.0.10
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/package.json
CHANGED
package/template/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// Packages / Helpers
|
|
2
2
|
|
|
3
3
|
const generateUniqueId = require('generate-unique-id');
|
|
4
|
-
const
|
|
4
|
+
const { global } = require('@/config/global');
|
|
5
5
|
|
|
6
6
|
async function generateId(customLength) {
|
|
7
7
|
const id = generateUniqueId({ length: customLength || 32 });
|
|
8
|
-
const exists = await redis.exists(`${process.env.PROJECT_ID}_ids_${id}`);
|
|
8
|
+
const exists = await global.redis.exists(`${process.env.PROJECT_ID}_ids_${id}`);
|
|
9
9
|
if (exists) return await generateId(customLength);
|
|
10
10
|
else {
|
|
11
|
-
await redis.set(`${process.env.PROJECT_ID}_ids_${id}`, '.');
|
|
11
|
+
await global.redis.set(`${process.env.PROJECT_ID}_ids_${id}`, '.');
|
|
12
12
|
return id;
|
|
13
13
|
}
|
|
14
14
|
}
|
package/template/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ require('module-alias/register');
|
|
|
6
6
|
// Packages / Helpers
|
|
7
7
|
|
|
8
8
|
const { SimpleSupabase } = require('simple-supabase');
|
|
9
|
-
const
|
|
9
|
+
const { createClient: createRedisClient } = require('redis');
|
|
10
10
|
const { global } = require('@/config/global');
|
|
11
11
|
|
|
12
12
|
// Start System
|
|
@@ -25,15 +25,16 @@ const { global } = require('@/config/global');
|
|
|
25
25
|
projectUrl: process.env.SUPABASE_PROJECT_URL,
|
|
26
26
|
serviceKey: process.env.SUPABASE_SECRET_KEY
|
|
27
27
|
},
|
|
28
|
-
clientOptions: {
|
|
29
|
-
auth: {
|
|
30
|
-
persistSession: false
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
28
|
redisPrefix: process.env.PROJECT_ID
|
|
34
29
|
});
|
|
35
30
|
|
|
36
31
|
global.db = db;
|
|
32
|
+
|
|
33
|
+
// Redis
|
|
34
|
+
|
|
35
|
+
const redis = createRedisClient();
|
|
36
|
+
await redis.connect();
|
|
37
|
+
|
|
37
38
|
global.redis = redis;
|
|
38
39
|
|
|
39
40
|
// ------- Start Here -------
|