Move plugins to express-twtkpr-core-plugins package

Add plugin structure
Fix stale cache after posting
Update to v0.9.0
This commit is contained in:
2026-05-12 23:43:26 -04:00
parent 298f267742
commit 8658a14200
103 changed files with 1632 additions and 1996 deletions

View File

@@ -1,8 +1,42 @@
import crypto from 'node:crypto';
import { createReadStream } from 'node:fs';
import { readFile, writeFile } from 'node:fs/promises';
import { PassThrough } from 'node:stream';
import jwt from 'jsonwebtoken';
import { v4 as uuidv4 } from 'uuid';
import { __dirname } from './constants.js';
async function combineWithPassthrough(sources: any[], destination: any) {
for (const stream of sources) {
await new Promise((resolve, reject) => {
let s = stream;
if (typeof stream === 'function') {
s = stream();
}
if (typeof s === 'string') {
destination.push(s);
destination.push(null);
resolve(true);
return;
}
s.pipe(destination, { end: false });
s.on('end', resolve);
s.on('error', reject);
});
}
destination.emit('end');
}
export function combineStreams(streams: any[]) {
const stream = new PassThrough();
combineWithPassthrough(streams, stream).catch((err) => stream.destroy(err));
return stream;
}
/**
*
* @param userId
@@ -51,6 +85,23 @@ export const getQueryParameterArray = (value: unknown | unknown[] = []) =>
? value.map((val) => `${val}`.trim())
: [`${value}`.trim()];
/**
*
* @param pathToFile
* @returns
*/
export const getReadStream = (pathToFile: string) => {
const theStream = createReadStream(pathToFile);
theStream.on('error', (err) => {
console.error(err);
theStream.close();
theStream.push(null);
});
return theStream;
};
/**
*
* @param value