Skip to content

Commit

Permalink
chore(deps): update all non polkadot-js deps (#988)
Browse files Browse the repository at this point in the history
* fix LRU instantiation in test

* chore(deps): update deps

* create ITransformableInfo type

* fix TransformableInfo typr

* update static dep

* Update src/logging/transports/consoleTransport.ts

Co-authored-by: Dominique <dsaripapazoglou@gmail.com>

* Update src/types/logging/Transformers.ts

Co-authored-by: Dominique <dsaripapazoglou@gmail.com>

* Update src/types/logging/index.ts

Co-authored-by: Dominique <dsaripapazoglou@gmail.com>

Co-authored-by: Dominique <dsaripapazoglou@gmail.com>
  • Loading branch information
TarikGul and Imod7 committed Jul 27, 2022
1 parent e003e93 commit 0facebf
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 319 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@
"@polkadot/util-crypto": "^10.1.1",
"@substrate/calc": "^0.2.8",
"argparse": "^2.0.1",
"confmgr": "1.0.7",
"express": "^4.17.1",
"express-winston": "^4.1.0",
"http-errors": "^1.8.1",
"lru-cache": "^6.0.0",
"rxjs": "^7.5.5",
"winston": "^3.3.3"
"confmgr": "1.0.9",
"express": "^4.18.1",
"express-winston": "^4.2.0",
"http-errors": "^2.0.0",
"lru-cache": "^7.13.1",
"rxjs": "^7.5.6",
"winston": "^3.8.1"
},
"devDependencies": {
"@substrate/dev": "^0.6.3",
"@types/argparse": "2.0.10",
"@types/express": "4.17.13",
"@types/express-serve-static-core": "4.17.25",
"@types/http-errors": "1.8.1",
"@types/lru-cache": "^5.1.1",
"@types/express-serve-static-core": "4.17.30",
"@types/http-errors": "1.8.2",
"@types/lru-cache": "^7.10.10",
"@types/morgan": "1.9.3",
"@types/triple-beam": "^1.3.2",
"tsc-watch": "^4.4.0"
"tsc-watch": "^4.6.2"
},
"resolutions": {
"node-fetch": "2.6.7",
Expand Down
5 changes: 3 additions & 2 deletions src/logging/transformers/filterApiRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { TransformableInfo } from 'logform';
import { format } from 'winston';

import { ITransformableInfo } from '../../types/logging';

/**
* Ignore log messages that have `API-WS:`. (e.g. polkadot-js RPC logging)
*/
export const filterApiRpc = format(
(info: TransformableInfo, _opts: unknown) => {
(info: ITransformableInfo, _opts: unknown) => {
if (
!info ||
(info?.message?.includes &&
Expand Down
5 changes: 3 additions & 2 deletions src/logging/transformers/stripTimestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { TransformableInfo } from 'logform';
import { format } from 'winston';

import { ITransformableInfo } from '../../types/logging';

/**
* Regex that matches timestamps with the format of `YYYY-MM-DD HH:MM`
*/
Expand All @@ -28,7 +29,7 @@ const timestampRegex =
* timestamp. This is for the polkadot-js console statements.
*/
export const stripTimestamp = format(
(info: TransformableInfo, _opts: unknown) => {
(info: ITransformableInfo, _opts: unknown) => {
if (timestampRegex.exec(info?.message)) {
info.message = info.message.slice(24).trim();
}
Expand Down
12 changes: 5 additions & 7 deletions src/logging/transports/consoleTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { TransformableInfo } from 'logform';
import { format, transports } from 'winston';

import { SidecarConfig } from '../../SidecarConfig';
import { ITransformableInfo } from '../../types/logging';
import {
filterApiRpc,
nodeUtilFormat,
Expand All @@ -34,17 +34,15 @@ export function consoleTransport(): transports.ConsoleTransportInstance {
config: { LOG },
} = SidecarConfig;
/**
* A simple printing format for how `TransformableInfo` shows up.
* A simple printing format for how `ITransformableInfo` shows up.
*/
const simplePrint = format.printf((info: TransformableInfo) => {
const simplePrint = format.printf((info: ITransformableInfo) => {
if (info?.stack) {
// If there is a stack dump (e.g. error middleware), show that in console
return `${info?.timestamp as string} ${info?.level}: ${
info?.message
} \n ${info?.stack as string}`;
return `${info?.timestamp} ${info?.level}: ${info?.message} \n ${info?.stack}`;
}

return `${info?.timestamp as string} ${info?.level}: ${info?.message}`;
return `${info?.timestamp} ${info?.level}: ${info?.message}`;
});

const transformers = [stripTimestamp(), nodeUtilFormat(), timeStamp];
Expand Down
2 changes: 1 addition & 1 deletion src/services/blocks/BlocksService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ describe('BlocksService', () => {
});

it('Returns true when queried blockId is canonical', async () => {
const blocksService = new BlocksService(mockApi, 0, new LRU());
const blocksService = new BlocksService(mockApi, 0, new LRU({ max: 2 }));
expect(
await blocksService['isFinalizedBlock'](
mockApi,
Expand Down
26 changes: 26 additions & 0 deletions src/types/logging/Transformers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

/**
* The logform package exports `TransformableInfo` but it sets the
* message type to `any`. Here we take that exact type and recreate it
* to have more specific type info.
*/
export interface ITransformableInfo {
level: string;
message: string;
[key: string]: string;
}
17 changes: 17 additions & 0 deletions src/types/logging/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

export * from './Transformers';
Loading

0 comments on commit 0facebf

Please sign in to comment.