Skip to content

Commit

Permalink
feat: unify cache interface
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Jun 17, 2023
1 parent 0a13a1c commit dc24a9b
Show file tree
Hide file tree
Showing 16 changed files with 468 additions and 185 deletions.
7 changes: 7 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

const oclif = require('@oclif/core');
const path = require('path');
const dotenv = require('dotenv');
const fs = require('fs-extra');

const envPath = path.resolve(process.cwd(), './.env')
const project = path.join(__dirname, '..', 'tsconfig.json');

if (fs.existsSync(envPath)) {
dotenv.config({ path: envPath })
}

// In dev mode -> use ts-node and dev plugins
process.env.NODE_ENV = 'development';

Expand Down
9 changes: 9 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#!/usr/bin/env node

const oclif = require('@oclif/core');
const dotenv = require('dotenv');
const { resolve } = require('path');
const fs = require('fs-extra');

const envPath = resolve(process.cwd(), './.env')

if (fs.existsSync(envPath)) {
dotenv.config({ path: envPath })
}

oclif
.run()
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
"ali-oss": "^6.17.1",
"bluebird": "^3.7.2",
"bytes": "^3.1.2",
"cache-manager": "^5.2.3",
"cache-manager-ioredis-yet": "^1.2.2",
"chalk": "^4.1.2",
"change-case": "^4.1.2",
"check-node-version": "^4.2.1",
Expand All @@ -99,7 +101,6 @@
"lodash": "^4.17.21",
"micromatch": "^4.0.5",
"ms": "^2.1.3",
"node-cache": "^5.1.2",
"node-dir": "^0.1.17",
"nunjucks": "^3.2.4",
"ora": "^5.4.1",
Expand Down
42 changes: 27 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

230 changes: 230 additions & 0 deletions src/__tests__/__snapshots__/index.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
{
cache: UnifiedCache {
del: AsyncFunction [],
get: AsyncFunction [],
keys: AsyncFunction [],
mdel: AsyncFunction [],
mget: AsyncFunction [],
mset: AsyncFunction [],
reset: AsyncFunction [],
set: AsyncFunction [],
},
categories: {
CLASH: 'Clash',
LOON: 'Loon',
Expand All @@ -30,6 +40,226 @@ Generated by [AVA](https://avajs.dev).
defineSurgioConfig: Function defineSurgioConfig {},
defineTrojanProvider: Function defineTrojanProvider {},
defineV2rayNSubscribeProvider: Function defineV2rayNSubscribeProvider {},
httpClient: Function got {
CacheError: Function CacheError {},
CancelError: Function CancelError {},
HTTPError: Function HTTPError {},
MaxRedirectsError: Function MaxRedirectsError {},
ParseError: Function ParseError {},
ReadError: Function ReadError {},
RequestError: Function RequestError {},
TimeoutError: Function TimeoutError {},
UnsupportedProtocolError: Function UnsupportedProtocolError {},
UploadError: Function UploadError {},
defaults: {
_rawHandlers: [
Function {},
],
handlers: [
Function {},
],
mutableDefaults: false,
options: {
agent: {
http: Agent {
_events: {
free: [
Function {},
Function {},
],
newListener: Function maybeEnableKeylog {},
},
_eventsCount: 2,
_maxListeners: undefined,
closeSocketCount: 0,
closeSocketCountLastCheck: 0,
createSocketCount: 0,
createSocketCountLastCheck: 0,
createSocketErrorCount: 0,
createSocketErrorCountLastCheck: 0,
defaultPort: 80,
errorSocketCount: 0,
errorSocketCountLastCheck: 0,
freeSockets: {},
keepAlive: true,
keepAliveMsecs: 1000,
maxFreeSockets: 256,
maxSockets: Infinity,
maxTotalSockets: Infinity,
options: {
freeSocketTimeout: 4000,
keepAlive: true,
noDelay: true,
path: null,
socketActiveTTL: 0,
timeout: 8000,
},
protocol: 'http:',
requestCount: 0,
requestCountLastCheck: 0,
requests: {},
scheduling: 'lifo',
sockets: {},
timeoutSocketCount: 0,
timeoutSocketCountLastCheck: 0,
totalSocketCount: 0,
[Symbol(kCapture)]: false,
[Symbol(agentkeepalive#currentId)]: 0,
},
https: HttpsAgent {
_events: {
free: [
Function {},
Function {},
],
newListener: Function maybeEnableKeylog {},
},
_eventsCount: 2,
_maxListeners: undefined,
_sessionCache: {
list: [],
map: {},
},
closeSocketCount: 0,
closeSocketCountLastCheck: 0,
createSocketCount: 0,
createSocketCountLastCheck: 0,
createSocketErrorCount: 0,
createSocketErrorCountLastCheck: 0,
defaultPort: 443,
errorSocketCount: 0,
errorSocketCountLastCheck: 0,
freeSockets: {},
keepAlive: true,
keepAliveMsecs: 1000,
maxCachedSessions: 100,
maxFreeSockets: 256,
maxSockets: Infinity,
maxTotalSockets: Infinity,
options: {
freeSocketTimeout: 4000,
keepAlive: true,
noDelay: true,
path: null,
socketActiveTTL: 0,
timeout: 8000,
},
protocol: 'https:',
requestCount: 0,
requestCountLastCheck: 0,
requests: {},
scheduling: 'lifo',
sockets: {},
timeoutSocketCount: 0,
timeoutSocketCountLastCheck: 0,
totalSocketCount: 0,
[Symbol(kCapture)]: false,
[Symbol(agentkeepalive#currentId)]: 0,
},
},
allowGetBody: false,
cache: undefined,
cacheOptions: {},
decompress: true,
dnsCache: undefined,
followRedirect: true,
headers: {
'user-agent': 'surgio/3.0.0-alpha.4',
},
hooks: {
afterResponse: [],
beforeError: [],
beforeRedirect: [],
beforeRequest: [],
beforeRetry: [],
init: [],
},
http2: false,
https: undefined,
ignoreInvalidCookies: false,
isStream: false,
maxRedirects: 10,
method: 'GET',
methodRewriting: true,
pagination: {
backoff: 0,
countLimit: Infinity,
filter: Function filter {},
paginate: Function paginate {},
requestLimit: 10000,
shouldContinue: Function shouldContinue {},
stackAllItems: true,
transform: Function transform {},
},
parseJson: Function parseJson {},
password: '',
prefixUrl: '',
resolveBodyOnly: false,
responseType: 'text',
retry: {
calculateDelay: Function calculateDelay {},
errorCodes: [
'ETIMEDOUT',
'ECONNRESET',
'EADDRINUSE',
'ECONNREFUSED',
'EPIPE',
'ENOTFOUND',
'ENETUNREACH',
'EAI_AGAIN',
],
limit: 0,
maxRetryAfter: Infinity,
methods: [
'GET',
'PUT',
'HEAD',
'DELETE',
'OPTIONS',
'TRACE',
],
statusCodes: [
408,
413,
429,
500,
502,
503,
504,
521,
522,
524,
],
},
stringifyJson: Function stringifyJson {},
throwHttpErrors: true,
timeout: {
request: 5000,
},
username: '',
},
},
delete: Function {},
extend: Function {},
get: Function {},
head: Function {},
mergeOptions: Function mergeOptions {},
paginate: AsyncGeneratorFunction {
all: AsyncFunction {},
each: [Circular],
},
patch: Function {},
post: Function {},
put: Function {},
stream: Function {
delete: Function {},
get: Function {},
head: Function {},
patch: Function {},
post: Function {},
put: Function {},
},
},
utils: {
SortFilterWithSortedFilters: Function SortFilterWithSortedFilters {},
SortFilterWithSortedKeywords: Function SortFilterWithSortedKeywords {},
Expand Down
Binary file modified src/__tests__/__snapshots__/index.test.ts.snap
Binary file not shown.
Loading

0 comments on commit dc24a9b

Please sign in to comment.