Skip to content

Commit

Permalink
chore(deps): ⬆️ update muliple dependencies and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolashenry committed Nov 30, 2024
1 parent 604c1b4 commit b687e72
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 220 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
"@typescript-eslint/no-unsafe-function-type": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-type-assertion": "warn",
"@typescript-eslint/no-unsafe-unary-minus": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": [
Expand Down Expand Up @@ -358,6 +359,7 @@
"@typescript-eslint/prefer-ts-expect-error": "off", // deprecated: replaced by @typescript-eslint/ban-ts-comment
"@typescript-eslint/promise-function-async": "warn",
"@typescript-eslint/quotes": "off", // deprecated: replaced by @stylistic/quotes
"@typescript-eslint/related-getter-setter-pairs": "warn",
"@typescript-eslint/require-array-sort-compare": "warn",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/restrict-plus-operands": "warn",
Expand Down
11 changes: 8 additions & 3 deletions examples/etag-hash-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ class EtagHashCacheStorage extends FileSystemStorage {
return new Promise<string>((resolve, reject) => {
stream.on('end', () => {
hash.end();
const newEtag = `"${ <string> hash.read() }"`;
this.etagCache.set(filePath, newEtag);
resolve(newEtag);
const etagStr = <unknown> hash.read();
if (typeof etagStr !== 'string') {
reject(new Error('hash calculation failed'));
return;
}
const etag = `"${ etagStr }"`;
this.etagCache.set(filePath, etag);
resolve(etag);
});
stream.on('error', err => {
reject(err);
Expand Down
1 change: 0 additions & 1 deletion examples/express-https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import { createServer } from 'node:https';
// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

Expand Down
1 change: 0 additions & 1 deletion examples/fastify-http2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This example shows how to use this library with Fastify using HTTP 2
*/

// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

Expand Down
1 change: 0 additions & 1 deletion examples/fastify-https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This example shows how to use this library with Fastify using HTTPS
*/

// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

Expand Down
1 change: 0 additions & 1 deletion examples/http2-module-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This example shows how to use this library with vanilla NodeJS http2 module (compat API)
*/

// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
import { createSecureServer } from 'node:http2';
Expand Down
1 change: 0 additions & 1 deletion examples/http2-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This example shows how to use this library with vanilla NodeJS http2 module
*/

// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import { createSecureServer } from 'node:http2';
import { join } from 'node:path';
Expand Down
1 change: 0 additions & 1 deletion examples/https-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This example shows how to use this library with vanilla NodeJS https module
*/

// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import { createServer } from 'node:https';
import { join } from 'node:path';
Expand Down
5 changes: 4 additions & 1 deletion examples/koa-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ app.use(async (ctx, next) => {
return;
}
ctx.status = result.statusCode;
ctx.set(<Record<string, string>> result.headers);
const headers = Object.fromEntries(
Object.entries(result.headers).map(([key, value]) => [key, String(value)]),
);
ctx.set(headers);
ctx.body = result.stream;
});

Expand Down
6 changes: 4 additions & 2 deletions examples/koa-http2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import { createSecureServer } from 'node:http2';
// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

Expand All @@ -23,7 +22,10 @@ app.use(async (ctx, next) => {
return;
}
ctx.status = result.statusCode;
ctx.set(<Record<string, string>> result.headers);
const headers = Object.fromEntries(
Object.entries(result.headers).map(([key, value]) => [key, String(value)]),
);
ctx.set(headers);
ctx.body = result.stream;
});

Expand Down
6 changes: 4 additions & 2 deletions examples/koa-https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import { createServer } from 'node:https';
// eslint-disable-next-line n/no-sync
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

Expand All @@ -23,7 +22,10 @@ app.use(async (ctx, next) => {
return;
}
ctx.status = result.statusCode;
ctx.set(<Record<string, string>> result.headers);
const headers = Object.fromEntries(
Object.entries(result.headers).map(([key, value]) => [key, String(value)]),
);
ctx.set(headers);
ctx.body = result.stream;
});

Expand Down
10 changes: 8 additions & 2 deletions examples/memory-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,20 @@ class FullCacheStorage extends GenericFileSystemStorage<CachedFileDescriptor> {
const hash = createHash('sha1');
hash.setEncoding('hex');
stream.on('data', chunk => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
chunks.push(<Buffer> chunk);
hash.write(chunk);
});
stream.on('error', reject);
stream.on('end', () => {
hash.end();
const newEtag = `"${ <string> hash.read() }"`;
const cache = { etag: newEtag, stats, chunks, size: chunks.reduce((p, c) => p + c.byteLength, 0) };
const etagStr = <unknown> hash.read();
if (typeof etagStr !== 'string') {
reject(new Error('hash calculation failed'));
return;
}
const etag = `"${ etagStr }"`;
const cache = { etag, stats, chunks, size: chunks.reduce((p, c) => p + c.byteLength, 0) };
this.cache.set(
filePath,
cache,
Expand Down
9 changes: 6 additions & 3 deletions examples/mongodb-gridfs-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ async function uploadToGridFS(rootPath: string, directoryPath: string, bucket: G
hashCopy,
hash,
);
const etag = `"${ <string> hash.read() }"`;
const etagStr = <unknown> hash.read();
if (typeof etagStr !== 'string') {
throw new TypeError('hash calculation failed');
}
const etag = `"${ etagStr }"`;
const uploadCopy = fs.createReadStream(filepath);
await promisifiedStreamPipeline(
uploadCopy,
// eslint-disable-next-line sonarjs/no-reference-error
<NodeJS.WritableStream> <unknown> bucket.openUploadStream(
bucket.openUploadStream(
relative(rootPath, filepath)
.split(sep)
.join('/'),
Expand Down
Loading

0 comments on commit b687e72

Please sign in to comment.