1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 12:21:00 -05:00

Compare commits

...

2 Commits

Author SHA1 Message Date
toast-ts
44768d9f59 Refactor get and set for Redis 2024-06-23 18:23:54 +10:00
toast-ts
72720359c0 Update dependencies 2024-06-23 16:46:05 +10:00
5 changed files with 83 additions and 114 deletions

View File

@ -1,5 +1,5 @@
FROM node:22.2.0-alpine3.20 FROM node:22.3-alpine3.20
ENV YARN_VERSION 4.3.0 ENV YARN_VERSION 4.3.1
ENV TZ Australia/Sydney ENV TZ Australia/Sydney
ENV NODE_COMPILE_CACHE /Daggerbot/build_cache ENV NODE_COMPILE_CACHE /Daggerbot/build_cache
RUN yarn policies set-version $YARN_VERSION RUN yarn policies set-version $YARN_VERSION

View File

@ -7,7 +7,7 @@ services:
- 6379:6379/tcp - 6379:6379/tcp
db: db:
container_name: daggerbot-postgres container_name: daggerbot-postgres
image: postgres:16.3-alpine3.19 image: postgres:16.3-alpine3.20
restart: unless-stopped restart: unless-stopped
ports: ports:
- 5432:5432/tcp - 5432:5432/tcp

View File

@ -25,10 +25,10 @@
"npm": "NPM isn't supported, please use Yarn instead." "npm": "NPM isn't supported, please use Yarn instead."
}, },
"engineStrict": true, "engineStrict": true,
"packageManager": "yarn@4.3.0+sha512.1606bef7c84bc7d83b8576063de2fd08f7d69f9939015bed800f9585a002390268ecc777e9feeba7e26e9556aef6beaad4806968db2182ab5dd3e955ab3b9a0b", "packageManager": "yarn@4.3.1+sha512.af78262d7d125afbfeed740602ace8c5e4405cd7f4735c08feb327286b2fdb2390fbca01589bfd1f50b1240548b74806767f5a063c94b67e431aabd0d86f7774",
"dependencies": { "dependencies": {
"@napi-rs/canvas": "0.1.53", "@napi-rs/canvas": "0.1.53",
"@octokit/rest": "20.1.1", "@octokit/rest": "21.0.0",
"@sequelize/core": "7.0.0-alpha.41", "@sequelize/core": "7.0.0-alpha.41",
"@sequelize/postgres": "7.0.0-alpha.41", "@sequelize/postgres": "7.0.0-alpha.41",
"@toast/tokenservice-client": "1.2.8", "@toast/tokenservice-client": "1.2.8",
@ -46,7 +46,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/ms": "0.7.34", "@types/ms": "0.7.34",
"@types/node": "20.14.6", "@types/node": "20.14.8",
"@types/node-cron": "3.0.11", "@types/node-cron": "3.0.11",
"typescript": "5.4.5" "typescript": "5.4.5"
} }

View File

@ -17,17 +17,11 @@ export default class CacheServer {
.on('error', (err:ErrorReply)=>Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`)) .on('error', (err:ErrorReply)=>Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`))
} }
public static async get(key:any, jsonMode:boolean):Promise<any> { public static async get(key:any, jsonMode:boolean):Promise<any> {
let cachedResult:any; const cachedResult = jsonMode ? await RedisClient.json.get(key) : await RedisClient.get(key);
if (jsonMode) cachedResult = await RedisClient.json.get(key); return jsonMode ? cachedResult : cachedResult ? JSON.parse(String(cachedResult)) : null;
else {
cachedResult = await RedisClient.get(key);
if (cachedResult) cachedResult = JSON.parse(cachedResult);
}
return cachedResult;
} }
public static async set(key:any, value:any, jsonMode:boolean):Promise<any> { public static async set(key:any, value:any, jsonMode:boolean):Promise<any> {
if (jsonMode) return await RedisClient.json.set(key, '.', value); return jsonMode ? await RedisClient.json.set(key, '.', value) : await RedisClient.set(key, JSON.stringify(value));
else return await RedisClient.set(key, JSON.stringify(value));
} }
/** @param time Cache expiration in seconds */ /** @param time Cache expiration in seconds */
public static expiry = async(key:any, time:number)=>await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong public static expiry = async(key:any, time:number)=>await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong

173
yarn.lock
View File

@ -235,46 +235,46 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/auth-token@npm:^4.0.0": "@octokit/auth-token@npm:^5.0.0":
version: 4.0.0 version: 5.1.1
resolution: "@octokit/auth-token@npm:4.0.0" resolution: "@octokit/auth-token@npm:5.1.1"
checksum: 10/60e42701e341d700f73c518c7a35675d36d79fa9d5e838cc3ade96d147e49f5ba74db2e07b2337c2b95aaa540aa42088116df2122daa25633f9e70a2c8785c44 checksum: 10/956ee8166ad1b623478ac5168529a081658bceb16e267102b149b44366a9280b5104a0346a4f1c5de12981d2dedb767f7b71d7e1b1ddd1ccb591efa8c6c06f94
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/core@npm:^5.0.2": "@octokit/core@npm:^6.1.2":
version: 5.2.0 version: 6.1.2
resolution: "@octokit/core@npm:5.2.0" resolution: "@octokit/core@npm:6.1.2"
dependencies: dependencies:
"@octokit/auth-token": "npm:^4.0.0" "@octokit/auth-token": "npm:^5.0.0"
"@octokit/graphql": "npm:^7.1.0" "@octokit/graphql": "npm:^8.0.0"
"@octokit/request": "npm:^8.3.1" "@octokit/request": "npm:^9.0.0"
"@octokit/request-error": "npm:^5.1.0" "@octokit/request-error": "npm:^6.0.1"
"@octokit/types": "npm:^13.0.0" "@octokit/types": "npm:^13.0.0"
before-after-hook: "npm:^2.2.0" before-after-hook: "npm:^3.0.2"
universal-user-agent: "npm:^6.0.0" universal-user-agent: "npm:^7.0.0"
checksum: 10/2e40baf0b5c6949922436a653c213be43befd9690c43dd89872f669f3ac23117ae8ae5e5d6c18094813756c71c3f4fbedd575a891f0b89e12f58b2c38b7f3c13 checksum: 10/ef8cc502790142d892b97b92a6e398323f1e4be777e5675681d5985d4681855f4e6f02a7b16466984af702ecdffed0ab923610d59c07c540c3e243160818eaec
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/endpoint@npm:^9.0.1": "@octokit/endpoint@npm:^10.0.0":
version: 9.0.5 version: 10.1.1
resolution: "@octokit/endpoint@npm:9.0.5" resolution: "@octokit/endpoint@npm:10.1.1"
dependencies: dependencies:
"@octokit/types": "npm:^13.1.0"
universal-user-agent: "npm:^6.0.0"
checksum: 10/212122f653bf076ec37dd7de44bd54db74aa3cd16be4c395c91444488331becd83351e26b30248168e2cc28fc07b1a96e8f74adbbab02826f76de92e069f391f
languageName: node
linkType: hard
"@octokit/graphql@npm:^7.1.0":
version: 7.1.0
resolution: "@octokit/graphql@npm:7.1.0"
dependencies:
"@octokit/request": "npm:^8.3.0"
"@octokit/types": "npm:^13.0.0" "@octokit/types": "npm:^13.0.0"
universal-user-agent: "npm:^6.0.0" universal-user-agent: "npm:^7.0.2"
checksum: 10/da6857a69dc93cd20a11d3a905db4214d269d246a6aaee1d8734f922024b08ffdef0b3cba2ac79917633043b4f50464242b0bd92a265c960083dfff5b833dbbe checksum: 10/6b8991b278ba7e63ddf95e7396f54e5f1347237f11fb845322ec25101764336ed0994ccb197c449b4fd4bc00ec5b78780ccbc3a0b48ba0620dcc115027a3add1
languageName: node
linkType: hard
"@octokit/graphql@npm:^8.0.0":
version: 8.1.1
resolution: "@octokit/graphql@npm:8.1.1"
dependencies:
"@octokit/request": "npm:^9.0.0"
"@octokit/types": "npm:^13.0.0"
universal-user-agent: "npm:^7.0.0"
checksum: 10/d8b3941e6afa724fba0cff79c71c839971aed6f87777833e1f6facc816c5fcd9a5b637dad779462cd723aa7490151f69fc6634758ca5bfe76f2cce298df934a1
languageName: node languageName: node
linkType: hard linkType: hard
@ -285,7 +285,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/plugin-paginate-rest@npm:11.3.1": "@octokit/plugin-paginate-rest@npm:^11.0.0":
version: 11.3.1 version: 11.3.1
resolution: "@octokit/plugin-paginate-rest@npm:11.3.1" resolution: "@octokit/plugin-paginate-rest@npm:11.3.1"
dependencies: dependencies:
@ -296,16 +296,16 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/plugin-request-log@npm:^4.0.0": "@octokit/plugin-request-log@npm:^5.1.0":
version: 4.0.1 version: 5.3.0
resolution: "@octokit/plugin-request-log@npm:4.0.1" resolution: "@octokit/plugin-request-log@npm:5.3.0"
peerDependencies: peerDependencies:
"@octokit/core": 5 "@octokit/core": ">=6"
checksum: 10/fd8c0a201490cba00084689a0d1d54fc7b5ab5b6bdb7e447056b947b1754f78526e9685400eab10d3522bfa7b5bc49c555f41ec412c788610b96500b168f3789 checksum: 10/8c918b14f0687e8a3d9c7c81ef1092a49de07681940cc1aee0aeb7e3dd8ac64f69af5d65932eec32f6db4af3dca80541ad3bb13ac0fa44af3e2340ed91909272
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/plugin-rest-endpoint-methods@npm:13.2.2": "@octokit/plugin-rest-endpoint-methods@npm:^13.0.0":
version: 13.2.2 version: 13.2.2
resolution: "@octokit/plugin-rest-endpoint-methods@npm:13.2.2" resolution: "@octokit/plugin-rest-endpoint-methods@npm:13.2.2"
dependencies: dependencies:
@ -316,38 +316,36 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/request-error@npm:^5.1.0": "@octokit/request-error@npm:^6.0.1":
version: 5.1.0 version: 6.1.1
resolution: "@octokit/request-error@npm:5.1.0" resolution: "@octokit/request-error@npm:6.1.1"
dependencies: dependencies:
"@octokit/types": "npm:^13.1.0" "@octokit/types": "npm:^13.0.0"
deprecation: "npm:^2.0.0" checksum: 10/cae7bc4078629a02edcf35977f496a4b943e730165f6d7828795073f99a1d884ac67343b02eff69e553a5057765e466d70ddd9d266787f505aa29018858ab06d
once: "npm:^1.4.0"
checksum: 10/d03f9f7a408af673cd991eeb450b6f4a5cee6c368f6349eb0211dfc0404fddfcff8b5225ef186020a2a1829adba0aa8c9174155b49ab2ed00a94fb9a886a1dd3
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/request@npm:^8.3.0, @octokit/request@npm:^8.3.1": "@octokit/request@npm:^9.0.0":
version: 8.4.0 version: 9.1.1
resolution: "@octokit/request@npm:8.4.0" resolution: "@octokit/request@npm:9.1.1"
dependencies: dependencies:
"@octokit/endpoint": "npm:^9.0.1" "@octokit/endpoint": "npm:^10.0.0"
"@octokit/request-error": "npm:^5.1.0" "@octokit/request-error": "npm:^6.0.1"
"@octokit/types": "npm:^13.1.0" "@octokit/types": "npm:^13.1.0"
universal-user-agent: "npm:^6.0.0" universal-user-agent: "npm:^7.0.2"
checksum: 10/176cd83c68bde87111a01d50e2d21cf12ec362c1a30b33649eb8771d37397f6d6dd0b0844aab8d59b16d74c825252e39cadd52e37a4b1669d6facd1cb2cdc995 checksum: 10/aef47d85751c387c6ef29e70b3b86c9033fc7940361092c80728f7e99cc0ba54ddd00bbecb4422e50df78744600cfb8a1a2bc6916c5b6440677aa8ebd6b9b291
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/rest@npm:20.1.1": "@octokit/rest@npm:21.0.0":
version: 20.1.1 version: 21.0.0
resolution: "@octokit/rest@npm:20.1.1" resolution: "@octokit/rest@npm:21.0.0"
dependencies: dependencies:
"@octokit/core": "npm:^5.0.2" "@octokit/core": "npm:^6.1.2"
"@octokit/plugin-paginate-rest": "npm:11.3.1" "@octokit/plugin-paginate-rest": "npm:^11.0.0"
"@octokit/plugin-request-log": "npm:^4.0.0" "@octokit/plugin-request-log": "npm:^5.1.0"
"@octokit/plugin-rest-endpoint-methods": "npm:13.2.2" "@octokit/plugin-rest-endpoint-methods": "npm:^13.0.0"
checksum: 10/a5d557323f3ebcf813bf0965f04084dc52e71525315f865646e084713099a2baa340752caebafb17595b31c5011df0f42a15359e145046d85b5051af37a516f9 checksum: 10/7da1c97866af04038fe4e384ce0a90cc4750bb951085c10053ceb73a4818cfe460336d7794ab3c65648cf5e195dba8e90940e36aec1e7ed22b6606cda38c88e0
languageName: node languageName: node
linkType: hard linkType: hard
@ -533,12 +531,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:*, @types/node@npm:20.14.6": "@types/node@npm:*, @types/node@npm:20.14.8":
version: 20.14.6 version: 20.14.8
resolution: "@types/node@npm:20.14.6" resolution: "@types/node@npm:20.14.8"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~5.26.4"
checksum: 10/1dcfeeb03ce3c3a1d8a537fefee7cd0cffb78f89e9535b74ee12940559566b57c39dad20d1b165b60b5727408dd44e1a52e5c01cf02d0a99d93ef3da8062c86e checksum: 10/73822f66f269ce865df7e2f586787ac7444bd1169fd265cbed1e851b72787f1170517c5b616e0308ec2fbc0934ec6403b0f28d4152acbb0486071aec41167d51
languageName: node languageName: node
linkType: hard linkType: hard
@ -570,9 +568,9 @@ __metadata:
linkType: hard linkType: hard
"@vladfrangu/async_event_emitter@npm:^2.2.4": "@vladfrangu/async_event_emitter@npm:^2.2.4":
version: 2.2.4 version: 2.3.0
resolution: "@vladfrangu/async_event_emitter@npm:2.2.4" resolution: "@vladfrangu/async_event_emitter@npm:2.3.0"
checksum: 10/06de49380dc47fe712768b0e49286e54a114de962da36ef021d4b03fcff7ec8338b46179d8b3eba4c0e02b2926bbf1e6ea0f9c6c08f6f081361947a7f6719ce9 checksum: 10/655a6bd2727e840b890be062ace1c0203f7fdd8ea2961029763fe0388512555c23935ad82c4f80900cb248146837582c103d7f6c293c10920b3b779377276d58
languageName: node languageName: node
linkType: hard linkType: hard
@ -592,10 +590,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"before-after-hook@npm:^2.2.0": "before-after-hook@npm:^3.0.2":
version: 2.2.3 version: 3.0.2
resolution: "before-after-hook@npm:2.2.3" resolution: "before-after-hook@npm:3.0.2"
checksum: 10/e676f769dbc4abcf4b3317db2fd2badb4a92c0710e0a7da12cf14b59c3482d4febf835ad7de7874499060fd4e13adf0191628e504728b3c5bb4ec7a878c09940 checksum: 10/57dfee78930276a740559552460a83f31c605e0164f02f170f71352aa1f4f5fb2c1632ac3bcba06ba711c32bd88b7e3c82431428e0c4984fbd2336faa78cf08c
languageName: node languageName: node
linkType: hard linkType: hard
@ -660,12 +658,12 @@ __metadata:
resolution: "daggerbot-ts@workspace:." resolution: "daggerbot-ts@workspace:."
dependencies: dependencies:
"@napi-rs/canvas": "npm:0.1.53" "@napi-rs/canvas": "npm:0.1.53"
"@octokit/rest": "npm:20.1.1" "@octokit/rest": "npm:21.0.0"
"@sequelize/core": "npm:7.0.0-alpha.41" "@sequelize/core": "npm:7.0.0-alpha.41"
"@sequelize/postgres": "npm:7.0.0-alpha.41" "@sequelize/postgres": "npm:7.0.0-alpha.41"
"@toast/tokenservice-client": "npm:1.2.8" "@toast/tokenservice-client": "npm:1.2.8"
"@types/ms": "npm:0.7.34" "@types/ms": "npm:0.7.34"
"@types/node": "npm:20.14.6" "@types/node": "npm:20.14.8"
"@types/node-cron": "npm:3.0.11" "@types/node-cron": "npm:3.0.11"
ansi-colors: "npm:4.1.3" ansi-colors: "npm:4.1.3"
dayjs: "npm:1.11.11" dayjs: "npm:1.11.11"
@ -708,13 +706,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"deprecation@npm:^2.0.0":
version: 2.3.1
resolution: "deprecation@npm:2.3.1"
checksum: 10/f56a05e182c2c195071385455956b0c4106fe14e36245b00c689ceef8e8ab639235176a96977ba7c74afb173317fac2e0ec6ec7a1c6d1e6eaa401c586c714132
languageName: node
linkType: hard
"discord-api-types@npm:0.37.83": "discord-api-types@npm:0.37.83":
version: 0.37.83 version: 0.37.83
resolution: "discord-api-types@npm:0.37.83" resolution: "discord-api-types@npm:0.37.83"
@ -959,15 +950,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"once@npm:^1.4.0":
version: 1.4.0
resolution: "once@npm:1.4.0"
dependencies:
wrappy: "npm:1"
checksum: 10/cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68
languageName: node
linkType: hard
"pg-cloudflare@npm:^1.1.1": "pg-cloudflare@npm:^1.1.1":
version: 1.1.1 version: 1.1.1
resolution: "pg-cloudflare@npm:1.1.1" resolution: "pg-cloudflare@npm:1.1.1"
@ -1378,10 +1360,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"universal-user-agent@npm:^6.0.0": "universal-user-agent@npm:^7.0.0, universal-user-agent@npm:^7.0.2":
version: 6.0.1 version: 7.0.2
resolution: "universal-user-agent@npm:6.0.1" resolution: "universal-user-agent@npm:7.0.2"
checksum: 10/fdc8e1ae48a05decfc7ded09b62071f571c7fe0bd793d700704c80cea316101d4eac15cc27ed2bb64f4ce166d2684777c3198b9ab16034f547abea0d3aa1c93c checksum: 10/3f02cb6de0bb9fbaf379566bd0320d8e46af6e4358a2e88fce7e70687ed7b48b37f479d728bb22f4204a518e363f3038ac4841c033af1ee2253f6428a6c67e53
languageName: node languageName: node
linkType: hard linkType: hard
@ -1419,13 +1401,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"wrappy@npm:1":
version: 1.0.2
resolution: "wrappy@npm:1.0.2"
checksum: 10/159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5
languageName: node
linkType: hard
"ws@npm:^8.16.0": "ws@npm:^8.16.0":
version: 8.17.1 version: 8.17.1
resolution: "ws@npm:8.17.1" resolution: "ws@npm:8.17.1"