Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrading typescript to 4.9.4 #214

Merged
merged 8 commits into from Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion package.json
Expand Up @@ -50,18 +50,25 @@
"@types/node": "^18.11.9",
"@types/responselike": "^1.0.0",
"@types/sqlite3": "^3.1.8",
"body-parser": "^1.20.1",
"create-cert": "^1.0.6",
"create-test-server": "3.0.1",
"delay": "^5.0.0",
"eslint-plugin-jest": "^27.1.5",
"express": "^4.18.2",
"jest": "^29.3.1",
"pify": "^6.1.0",
"sqlite3": "^5.1.2",
"ts-jest": "^29.0.3",
"ts-jest-resolver": "^2.0.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.3",
"typescript": "^4.9.4",
"xo": "^0.53.1"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{ts,js}"
],
"extensionsToTreatAsEsm": [
".ts"
],
Expand Down Expand Up @@ -100,6 +107,7 @@
"@typescript-eslint/restrict-template-expressions": 0,
"@typescript-eslint/no-unsafe-return": 0,
"new-cap": 0,
"unicorn/no-abusive-eslint-disable": 0,
"@typescript-eslint/restrict-plus-operands": 0,
"@typescript-eslint/no-implicit-any-catch": 0,
"@typescript-eslint/consistent-type-imports": 0,
Expand Down
2 changes: 1 addition & 1 deletion test/cache.test.ts
Expand Up @@ -3,11 +3,11 @@ import url from 'node:url';
import util, {promisify as pm} from 'node:util';
import {gzip, gunzip} from 'node:zlib';
import getStream from 'get-stream';
import createTestServer from 'create-test-server';
import delay from 'delay';
import sqlite3 from 'sqlite3';
import Keyv from 'keyv';
import CacheableRequest, {CacheValue, onResponse} from '../src/index.js';
import createTestServer from './create-test-server/index.mjs';

// Promisify cacheableRequest
const promisify = (cacheableRequest: any) => async (options: any) => new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion test/cacheable-request-instance.test.ts
Expand Up @@ -2,10 +2,10 @@ import EventEmitter from 'node:events';
import {request} from 'node:http';
import stream from 'node:stream';
import url from 'node:url';
import createTestServer from 'create-test-server';
import getStream from 'get-stream';
import CacheableRequest from '../src/index.js';
import {CacheError, RequestError} from '../src/types.js';
import createTestServer from './create-test-server/index.mjs';

let s: any;
beforeAll(async () => {
Expand Down
58 changes: 58 additions & 0 deletions test/create-test-server/index.mjs
@@ -0,0 +1,58 @@
/* eslint-disable */
'use strict';

import http from 'node:http';
import express from 'express';
import pify from 'pify';
import bodyParser from 'body-parser';

const createTestServer = (opts = {}) => {
const server = express();
server.http = http.createServer(server);

server.set('etag', false);

if (opts.bodyParser !== false) {
server.use(bodyParser.json(Object.assign({ limit: '1mb', type: 'application/json' }, opts.bodyParser)));
server.use(bodyParser.text(Object.assign({ limit: '1mb', type: 'text/plain' }, opts.bodyParser)));
server.use(bodyParser.urlencoded(Object.assign({ limit: '1mb', type: 'application/x-www-form-urlencoded', extended: true }, opts.bodyParser)));
server.use(bodyParser.raw(Object.assign({ limit: '1mb', type: 'application/octet-stream' }, opts.bodyParser)));
}

const send = fn => (req, res, next) => {
const cb = typeof fn === 'function' ? fn(req, res, next) : fn;

Promise.resolve(cb).then(val => {
if (val) {
res.send(val);
}
});
};

const get = server.get.bind(server);
server.get = function () {
const [path, ...handlers] = [...arguments];

for (const handler of handlers) {
get(path, send(handler));
}
};

server.listen = () => Promise.all([
pify(server.http.listen.bind(server.http))().then(() => {
server.port = server.http.address().port;
server.url = `http://localhost:${server.port}`;
})
]);

server.close = () => Promise.all([
pify(server.http.close.bind(server.http))().then(() => {
server.port = undefined;
server.url = undefined;
})
]);

return server.listen().then(() => server);
};

export default createTestServer;
2 changes: 1 addition & 1 deletion tsconfig.json
Expand Up @@ -76,7 +76,7 @@
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand Down