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 CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "podverse-helpers",
3
- "version": "5.0.0-beta.2",
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
@@ -1,6 +0,0 @@
1
- {
2
- "ext": "ts",
3
- "env": {
4
- "NODE_ENV": "development"
5
- }
6
- }
@@ -1,5 +0,0 @@
1
- export const config = {
2
- nodeEnv: process.env.NODE_ENV || 'development',
3
- userAgent: process.env.USER_AGENT || '',
4
- logLevel: process.env.LOG_LEVEL || 'info',
5
- };
package/src/index.ts DELETED
@@ -1,9 +0,0 @@
1
- import './module-alias-config';
2
-
3
- export * from './lib/array';
4
- export * from './lib/boolean';
5
- export * from './lib/debug';
6
- export * from './lib/hash';
7
- export * from './lib/logger';
8
- export * from './lib/request';
9
- export * from './lib/sortableTitle';
package/src/lib/array.ts DELETED
@@ -1,7 +0,0 @@
1
- export function chunkArray<T>(array: T[], chunkSize: number): T[][] {
2
- const chunks: T[][] = [];
3
- for (let i = 0; i < array.length; i += chunkSize) {
4
- chunks.push(array.slice(i, i + chunkSize));
5
- }
6
- return chunks;
7
- }
@@ -1,9 +0,0 @@
1
- export const getBooleanOrNull = (value: boolean | null): boolean | null => {
2
- if (value === true) {
3
- return true;
4
- } else if (value === false) {
5
- return false;
6
- }
7
-
8
- return null;
9
- };
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
@@ -1,6 +0,0 @@
1
- import crypto from 'crypto';
2
-
3
- export const getMd5Hash = (data: unknown): string => {
4
- const parsedFeedString = JSON.stringify(data);
5
- return crypto.createHash('md5').update(parsedFeedString).digest('hex');
6
- };
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
- };
@@ -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
- };
@@ -1,7 +0,0 @@
1
- export function createSortableTitle(input: string): string {
2
- return input
3
- .toLowerCase()
4
- .trim()
5
- .replace(/\s+/g, '')
6
- .replace(/[^a-z0-9]/g, '');
7
- }
@@ -1,8 +0,0 @@
1
- const moduleAlias = require('module-alias');
2
- const path = require('path');
3
-
4
- moduleAlias.addAliases({
5
- '@helpers': path.join(__dirname, '')
6
- });
7
-
8
- export {};
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
- }