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

Use common logger #69

Merged
merged 6 commits into from
Oct 10, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ A monorepo for managing signed data. Consists of:

- [api](./packages/api/README.md) - A service for storing and accessing signed data. It provides endpoints to handle
signed data for a specific airnode.
- [common](./packages/common/README.md) - An internal-only package with common types and utilities used by other
packages.
- [pusher](./packages/pusher/README.md) - A service for pushing data provider signed data.
- [e2e](./packages/e2e/README.md) - End to end test utilizing Mock API, pusher and signed API.

Expand Down
2 changes: 1 addition & 1 deletion packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ AWS_S3_BUCKET_NAME=my-config-bucket
AWS_S3_BUCKET_PATH=configs/my-app/signed-api.json
```

<!-- NOTE: Keep the logger configuration in-sync with logger and pusher. -->
<!-- NOTE: Keep the logger configuration in-sync with pusher. -->

#### `LOGGER_ENABLED`

Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"nodemon": "^3.0.1"
},
"dependencies": {
"@api3/commons": "^0.1.0",
"@api3/promise-utils": "^0.4.0",
"@aws-sdk/client-s3": "^3.421.0",
"dotenv": "^16.3.1",
"ethers": "^5.7.2",
"express": "^4.18.2",
"lodash": "^4.17.21",
"signed-api/common": "workspace:common@*",
"zod": "^3.22.3"
}
}
6 changes: 2 additions & 4 deletions packages/api/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { createLogger, logConfigSchema } from 'signed-api/common';
import { createLogger } from '@api3/commons/logger';

import { loadEnv } from './env';

// We need to load the environment variables before we can use the logger. Because we want the logger to always be
// available, we load the environment variables as a side effect during the module import.
const env = loadEnv();

const options = logConfigSchema.parse({
export const logger = createLogger({
colorize: env.LOG_COLORIZE,
enabled: env.LOGGER_ENABLED,
minLevel: env.LOG_LEVEL,
format: env.LOG_FORMAT,
});

export const logger = createLogger(options);
2 changes: 1 addition & 1 deletion packages/api/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('env config schema', () => {
expect(() => envConfigSchema.parse(env)).not.toThrow();
});

it('aWS_REGION is set when CONFIG_SOURCE is aws-s3', () => {
it('the AWS_REGION is set when CONFIG_SOURCE is aws-s3', () => {
Siegrift marked this conversation as resolved.
Show resolved Hide resolved
const env = {
CONFIG_SOURCE: 'aws-s3',
};
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logFormatSchema, logLevelSchema } from '@api3/commons/logger';
import { uniqBy } from 'lodash';
import { logFormatSchema, logLevelSchema } from 'signed-api/common';
import { z } from 'zod';

export const endpointSchema = z
Expand Down
22 changes: 1 addition & 21 deletions packages/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
{
"compilerOptions": {
"noEmit": true,
"lib": ["esnext"],
"module": "commonjs",
"esModuleInterop": true,
"moduleResolution": "node",
"strict": true,
"target": "esnext",
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"exactOptionalPropertyTypes": true,
"noUncheckedIndexedAccess": true,
"noImplicitReturns": true,

// Disabled because they are covered by Eslint rules
"noUnusedLocals": false,
"noUnusedParameters": false,

// Disabled because prefer the property syntax
"noPropertyAccessFromIndexSignature": false
},
"extends": "../../tsconfig.json",
"exclude": ["dist/**/*", "node_modules/**/*"],
"include": ["./src/**/*", "./test/**/*", "jest.config.js"]
}
1 change: 0 additions & 1 deletion packages/common/.eslintignore

This file was deleted.

1 change: 0 additions & 1 deletion packages/common/.prettierignore

This file was deleted.

16 changes: 0 additions & 16 deletions packages/common/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/common/jest.config.js

This file was deleted.

25 changes: 0 additions & 25 deletions packages/common/package.json

This file was deleted.

14 changes: 0 additions & 14 deletions packages/common/src/index.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/common/src/index.ts

This file was deleted.

39 changes: 0 additions & 39 deletions packages/common/src/logger/README.md

This file was deleted.

107 changes: 0 additions & 107 deletions packages/common/src/logger/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/common/tsconfig.build.json

This file was deleted.

25 changes: 0 additions & 25 deletions packages/common/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
},
"license": "MIT",
"dependencies": {
"@api3/commons": "^0.1.0",
"@api3/promise-utils": "^0.4.0",
"axios": "^1.5.1",
"ethers": "^5.7.2",
"express": "^4.18.2",
"lodash": "^4.17.21",
"signed-api/common": "workspace:common@*",
"zod": "^3.22.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createLogger } from 'signed-api/common';
import { createLogger } from '@api3/commons/logger';

export const logger = createLogger({
colorize: true,
Expand Down
Loading