podverse-helpers 5.0.0-beta.2 → 5.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/package.json +4 -1
- package/.nvmrc +0 -1
- package/eslint.config.mjs +0 -38
- package/nodemon.json +0 -6
- package/src/config/index.ts +0 -5
- package/src/index.ts +0 -9
- package/src/lib/array.ts +0 -7
- package/src/lib/boolean.ts +0 -9
- package/src/lib/debug.ts +0 -7
- package/src/lib/hash.ts +0 -6
- package/src/lib/logger.ts +0 -34
- package/src/lib/request.ts +0 -61
- package/src/lib/sortableTitle.ts +0 -7
- package/src/module-alias-config.ts +0 -8
- package/tsconfig.json +0 -25
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-helpers",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
7
10
|
"scripts": {
|
|
8
11
|
"dev:watch": "nodemon --watch 'src' --watch $(realpath node_modules/podverse-external-services) --watch $(realpath node_modules/podverse-orm) --watch $(realpath node_modules/podverse-shared) -x \"npm run build\"",
|
|
9
12
|
"build": "tsc",
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v20.16.0
|
package/eslint.config.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import globals from "globals";
|
|
2
|
-
import pluginJs from "@eslint/js";
|
|
3
|
-
import tseslint from "@typescript-eslint/eslint-plugin";
|
|
4
|
-
import tsParser from "@typescript-eslint/parser";
|
|
5
|
-
|
|
6
|
-
const pluginJsRecommended = {
|
|
7
|
-
rules: {
|
|
8
|
-
...pluginJs.configs.recommended.rules,
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const tseslintRecommended = {
|
|
13
|
-
rules: {
|
|
14
|
-
...tseslint.configs.recommended.rules,
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default [
|
|
19
|
-
{
|
|
20
|
-
files: ["src/**/*.{js,ts}"],
|
|
21
|
-
languageOptions: {
|
|
22
|
-
globals: globals.node,
|
|
23
|
-
parser: tsParser,
|
|
24
|
-
},
|
|
25
|
-
plugins: {
|
|
26
|
-
"@typescript-eslint": tseslint,
|
|
27
|
-
},
|
|
28
|
-
rules: {
|
|
29
|
-
...pluginJsRecommended.rules,
|
|
30
|
-
...tseslintRecommended.rules,
|
|
31
|
-
"semi": ["error", "always"],
|
|
32
|
-
"indent": ["error", 2],
|
|
33
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
34
|
-
},
|
|
35
|
-
ignores: ["**/eslint.config.mjs"],
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
|
package/nodemon.json
DELETED
package/src/config/index.ts
DELETED
package/src/index.ts
DELETED
package/src/lib/array.ts
DELETED
package/src/lib/boolean.ts
DELETED
package/src/lib/debug.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const fs = require('fs').promises;
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
export async function saveObjectAsFileLocally(obj: object): Promise<void> {
|
|
5
|
-
const filePath = path.join(__dirname, 'saveObjectAsFileLocally.json');
|
|
6
|
-
await fs.writeFile(filePath, JSON.stringify(obj, null, 2), 'utf8');
|
|
7
|
-
}
|
package/src/lib/hash.ts
DELETED
package/src/lib/logger.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { config } from '@helpers/config';
|
|
2
|
-
import { createLogger, format, transports } from 'winston';
|
|
3
|
-
import * as TransportStream from 'winston-transport';
|
|
4
|
-
|
|
5
|
-
const { combine, timestamp, printf, colorize } = format;
|
|
6
|
-
|
|
7
|
-
const logFormat = printf(({ level, message, timestamp, stack }) => {
|
|
8
|
-
return stack ? `${timestamp} [${level}]: ${message} - ${stack}` : `${timestamp} [${level}]: ${message}`;
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export const logger = createLogger({
|
|
12
|
-
level: config.logLevel,
|
|
13
|
-
format: combine(
|
|
14
|
-
timestamp(),
|
|
15
|
-
logFormat
|
|
16
|
-
),
|
|
17
|
-
transports: [
|
|
18
|
-
new transports.Console({
|
|
19
|
-
format: combine(
|
|
20
|
-
colorize(),
|
|
21
|
-
timestamp(),
|
|
22
|
-
logFormat
|
|
23
|
-
)
|
|
24
|
-
})
|
|
25
|
-
]
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export const addRemoteTransport = (transport: TransportStream) => {
|
|
29
|
-
logger.add(transport);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const logError = (error: Error) => {
|
|
33
|
-
logger.error(error.message, { stack: error.stack });
|
|
34
|
-
};
|
package/src/lib/request.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { config } from '@helpers/config';
|
|
3
|
-
|
|
4
|
-
export const request = async <T>(
|
|
5
|
-
url: string,
|
|
6
|
-
requestConfig?: AxiosRequestConfig,
|
|
7
|
-
abort?: {
|
|
8
|
-
controller: AbortController
|
|
9
|
-
timeoutMs: number
|
|
10
|
-
}
|
|
11
|
-
): Promise<T> => {
|
|
12
|
-
// eslint-disable-next-line no-undef
|
|
13
|
-
let timeoutId: NodeJS.Timeout | undefined;
|
|
14
|
-
if (abort) {
|
|
15
|
-
timeoutId = setTimeout(() => {
|
|
16
|
-
abort.controller.abort();
|
|
17
|
-
}, abort.timeoutMs);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
const response: AxiosResponse<T> = await axios.request<T>({
|
|
22
|
-
url,
|
|
23
|
-
method: 'GET',
|
|
24
|
-
headers: {
|
|
25
|
-
'User-Agent': config?.userAgent,
|
|
26
|
-
...requestConfig?.headers
|
|
27
|
-
},
|
|
28
|
-
signal: abort?.controller?.signal,
|
|
29
|
-
...requestConfig
|
|
30
|
-
});
|
|
31
|
-
return response.data;
|
|
32
|
-
} catch (error) {
|
|
33
|
-
if (axios.isCancel(error)) {
|
|
34
|
-
console.error('Request canceled', error.message);
|
|
35
|
-
} else {
|
|
36
|
-
console.error('Error fetching data', error);
|
|
37
|
-
}
|
|
38
|
-
throw error;
|
|
39
|
-
} finally {
|
|
40
|
-
if (timeoutId) {
|
|
41
|
-
clearTimeout(timeoutId);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
interface ErrorWithStatusCode extends Error {
|
|
47
|
-
statusCode?: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const throwRequestError = (error: unknown): never => {
|
|
51
|
-
if (error instanceof Error) {
|
|
52
|
-
const errorWithStatusCode = error as ErrorWithStatusCode;
|
|
53
|
-
if (errorWithStatusCode.statusCode) {
|
|
54
|
-
throw new Error(`HTTP Error: ${errorWithStatusCode.statusCode} - ${error.message}`);
|
|
55
|
-
} else {
|
|
56
|
-
throw new Error(`Unknown Error: ${error.message}`);
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
throw new Error('An unexpected error occurred');
|
|
60
|
-
}
|
|
61
|
-
};
|
package/src/lib/sortableTitle.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES6",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"strict": true,
|
|
6
|
-
"noImplicitAny": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"emitDecoratorMetadata": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"declarationMap": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"rootDir": "./src",
|
|
16
|
-
"baseUrl": "./",
|
|
17
|
-
"paths": {
|
|
18
|
-
"@helpers/*": ["src/*"]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"include": [
|
|
22
|
-
"./src/**/*.ts"
|
|
23
|
-
],
|
|
24
|
-
"exclude": ["node_modules"]
|
|
25
|
-
}
|