Skip to content

Commit

Permalink
Fix compilation errors in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolman committed May 18, 2024
1 parent 1713828 commit 1a26d1a
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 24 deletions.
2 changes: 0 additions & 2 deletions apps/api/src/app/controllers/health/list.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Request, Response } from 'express';
import newrelic from 'newrelic';
import { fromWei } from 'web3-utils';
import { NODE_ENV } from '@thxnetwork/api/config/secrets';
import { ChainId } from '@thxnetwork/common/enums';
Expand All @@ -10,7 +9,6 @@ import { getArtifact, contractNetworks } from '@thxnetwork/api/hardhat';
import { BigNumber } from 'alchemy-sdk';

function handleError(error: Error) {
newrelic.noticeError(error);
logger.error(error);
return { error: 'invalid response' };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as CreateEntry from './entries/post.controller';
import { assertRequestInput, assertAccount } from '@thxnetwork/api/middlewares';
import { limitInSeconds } from '@thxnetwork/api/util/ratelimiter';

export const router: express.Router = express.Router({ mergeParams: true });
const router: express.Router = express.Router({ mergeParams: true });

router.post(
'/:id/entries',
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/controllers/quests/daily/daily.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as CreateEntry from './entries/post.controller';
import { assertAccount, assertRequestInput } from '@thxnetwork/api/middlewares';
import { limitInSeconds } from '@thxnetwork/api/util/ratelimiter';

export const router: express.Router = express.Router({ mergeParams: true });
const router: express.Router = express.Router({ mergeParams: true });

router.post(
'/:id/entries',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as CreateEntry from './entries/post.controller';
import { assertRequestInput, assertAccount } from '@thxnetwork/api/middlewares';
import { limitInSeconds } from '@thxnetwork/api/util/ratelimiter';

export const router: express.Router = express.Router({ mergeParams: true });
const router: express.Router = express.Router({ mergeParams: true });

router.post(
'/:id/entries',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { QuestSocialRequirement } from '@thxnetwork/common/enums';

const validation = [param('id').isMongoId(), body('recaptcha').isString()];

const controller = async ({ params, body, account }: Request, res: Response) => {
async function controller({ params, body, account }: Request, res: Response) {
// Get the quest document
const quest = await QuestSocial.findById(params.id);
if (!quest) throw new NotFoundError('Quest not found');
Expand Down Expand Up @@ -63,6 +63,6 @@ const controller = async ({ params, body, account }: Request, res: Response) =>
});

res.json({ jobId: job.attrs._id });
};
}

export { controller, validation };
14 changes: 10 additions & 4 deletions apps/api/src/app/controllers/quests/social/social.router.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import express from 'express';
import express, { Router } from 'express';
import { assertRequestInput, assertAccount } from '@thxnetwork/api/middlewares';
import { limitInSeconds } from '@thxnetwork/api/util/ratelimiter';
import * as Create from './entries/post.controller';
import * as CreateEntries from './entries/post.controller';

export const router: express.Router = express.Router({ mergeParams: true });
const router: express.Router = Router({ mergeParams: true });

router.post('/:id/entries', limitInSeconds(3), assertRequestInput(Create.validation), assertAccount, Create.controller);
router.post(
'/:id/entries',
limitInSeconds(3),
assertRequestInput(CreateEntries.validation),
assertAccount,
CreateEntries.controller,
);

export default router;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assertAccount, assertRequestInput } from '@thxnetwork/api/middlewares';
import { limitInSeconds } from '@thxnetwork/api/util/ratelimiter';
import * as CreateEntry from './entries/post.controller';

export const router: express.Router = express.Router({ mergeParams: true });
const router: express.Router = express.Router({ mergeParams: true });

router.post(
'/:id/entries',
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/controllers/ve/ve.router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import express, { Router } from 'express';
import express from 'express';
import { assertRequestInput } from '@thxnetwork/api/middlewares';
import { assertWallet } from '@thxnetwork/api/middlewares/assertWallet';

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/util/ratelimiter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import rateLimit from 'express-rate-limit';
import { NODE_ENV } from '../config/secrets';

const limitInSeconds = (seconds: number) => NODE_ENV !== 'test' && rateLimit({ windowMs: seconds * 1000, max: 1 });
const limitInSeconds = (seconds: number) => rateLimit({ windowMs: NODE_ENV !== 'test' && seconds * 1000, max: 1 });

export { limitInSeconds };
5 changes: 1 addition & 4 deletions apps/api/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
// Custom
"noImplicitAny": false,
"strict": false
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.test.ts", "../../libs/common/src/lib/scss/**/*"],
"include": ["src/**/*.ts", "../../libs/common/src/**/*", "../../libs/sdk/src/**/*", "src/app/hardhat/export/*.json"]
Expand Down
11 changes: 7 additions & 4 deletions apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"esModuleInterop": true,
// Custom
"noImplicitAny": false,
"strict": false
},
"files": [],
"include": [],
"references": [
Expand All @@ -9,8 +15,5 @@
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
}
]
}
12 changes: 10 additions & 2 deletions apps/api/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
"types": ["jest", "node"],
// Custom
"allowJs": true
},
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"**/*.d.ts",
"../../libs/common/src/lib/types/**/*"
]
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,16 @@
"@typechain/hardhat": "^6.1.2",
"@types/chai": "^4.2.0",
"@types/color": "^3.0.3",
"@types/compression": "^1.7.5",
"@types/ejs": "^3.1.5",
"@types/express": "~4.17.13",
"@types/jest": "29.4.4",
"@types/lusca": "^1.7.5",
"@types/migrate-mongo": "^10.0.4",
"@types/mixpanel-browser": "^2.38.0",
"@types/mocha": ">=9.1.0",
"@types/node": ">=18.0.0",
"@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
Expand Down
41 changes: 41 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7525,6 +7525,13 @@
dependencies:
"@types/color-convert" "*"

"@types/compression@^1.7.5":
version "1.7.5"
resolved "https://registry.yarnpkg.com/@types/compression/-/compression-1.7.5.tgz#0f80efef6eb031be57b12221c4ba6bc3577808f7"
integrity sha512-AAQvK5pxMpaT+nDvhHrsBhLSYG5yQdtkaJE1WYieSNY2mVFKAgmU4ks65rkZD5oqnGCFLyQpUr1CqI4DmUMyDg==
dependencies:
"@types/express" "*"

"@types/concat-stream@^1.6.0":
version "1.6.1"
resolved "https://registry.yarnpkg.com/@types/concat-stream/-/concat-stream-1.6.1.tgz#24bcfc101ecf68e886aaedce60dfd74b632a1b74"
Expand All @@ -7547,6 +7554,11 @@
dependencies:
"@types/node" "*"

"@types/cookiejar@^2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.5.tgz#14a3e83fa641beb169a2dd8422d91c3c345a9a78"
integrity sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==

"@types/debug@^4.1.7":
version "4.1.12"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.12.tgz#a155f21690871953410df4b6b6f53187f0500917"
Expand Down Expand Up @@ -7734,6 +7746,18 @@
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.1.tgz#c48c2e27b65d2a153b19bfc1a317e30872e01eef"
integrity sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==

"@types/lusca@^1.7.5":
version "1.7.5"
resolved "https://registry.yarnpkg.com/@types/lusca/-/lusca-1.7.5.tgz#6fff257dc11176bd3150afba90790e626a12cd0f"
integrity sha512-l49gAf8pu2iMzbKejLcz6Pqj+51H2na6BgORv1ElnE8ByPFcBdh/eZ0WNR1Va/6ZuNSZa01Hoy1DTZ3IZ+y+kA==
dependencies:
"@types/express" "*"

"@types/methods@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@types/methods/-/methods-1.1.4.tgz#d3b7ac30ac47c91054ea951ce9eed07b1051e547"
integrity sha512-ymXWVrDiCxTBE3+RIrrP533E70eA+9qu7zdWoHuOmGujkYtzf4HQF96b8nwHLqhuf4ykX61IGRIB38CC6/sImQ==

"@types/migrate-mongo@^10.0.4":
version "10.0.4"
resolved "https://registry.yarnpkg.com/@types/migrate-mongo/-/migrate-mongo-10.0.4.tgz#5b68fb9c3ca516e4f025ebca34021880137f94a4"
Expand Down Expand Up @@ -7966,6 +7990,23 @@
resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==

"@types/superagent@^8.1.0":
version "8.1.7"
resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-8.1.7.tgz#1153819ed4db34427409a1cc58f3e2f13eeec862"
integrity sha512-NmIsd0Yj4DDhftfWvvAku482PZum4DBW7U51OvS8gvOkDDY0WT1jsVyDV3hK+vplrsYw8oDwi9QxOM7U68iwww==
dependencies:
"@types/cookiejar" "^2.1.5"
"@types/methods" "^1.1.4"
"@types/node" "*"

"@types/supertest@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-6.0.2.tgz#2af1c466456aaf82c7c6106c6b5cbd73a5e86588"
integrity sha512-137ypx2lk/wTQbW6An6safu9hXmajAifU/s7szAHLN/FeIm5w7yR0Wkl9fdJMRSHwOn4HLAI0DaB2TOORuhPDg==
dependencies:
"@types/methods" "^1.1.4"
"@types/superagent" "^8.1.0"

"@types/tapable@^1":
version "1.0.12"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.12.tgz#bc2cab12e87978eee89fb21576b670350d6d86ab"
Expand Down

0 comments on commit 1a26d1a

Please sign in to comment.