Skip to content

Commit

Permalink
nestjs@11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
iamolegga committed Jan 21, 2025
1 parent e399d85 commit 1c3c3f7
Show file tree
Hide file tree
Showing 14 changed files with 1,828 additions and 2,169 deletions.
74 changes: 37 additions & 37 deletions .eslintrc.js → .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:prettier/recommended',
"plugins": ["@typescript-eslint/eslint-plugin"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:prettier/recommended"
],
root: true,
env: {
node: true,
jest: true,
"root": true,
"env": {
"node": true,
"jest": true
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/no-explicit-any': [
'error',
{ fixToUnknown: true, ignoreRestArgs: false },
"ignorePatterns": [".eslintrc.js"],
"rules": {
"@typescript-eslint/no-explicit-any": [
"error",
{ "fixToUnknown": true, "ignoreRestArgs": false }
],
'@typescript-eslint/no-floating-promises': ['error', { ignoreIIFE: true }],
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true },
"@typescript-eslint/no-floating-promises": ["error", { "ignoreIIFE": true }],
"@typescript-eslint/no-unused-vars": [
"error",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_", "ignoreRestSiblings": true }
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{ accessibility: 'no-public' },
"@typescript-eslint/explicit-member-accessibility": [
"error",
{ "accessibility": "no-public" }
],
'@typescript-eslint/member-ordering': ['error', {
default: [
"@typescript-eslint/member-ordering": ["error", {
"default": [
"public-static-field",
"public-static-get",
"public-static-set",
Expand Down Expand Up @@ -85,15 +85,15 @@ module.exports = {
"private-decorated-set",
"private-instance-set",
"private-decorated-method",
"private-instance-method",
"private-instance-method"
]
}],
'import/order': [
'error',
"import/order": [
"error",
{
alphabetize: { order: 'asc', caseInsensitive: true },
'newlines-between': 'always',
},
"alphabetize": { "order": "asc", "caseInsensitive": true },
"newlines-between": "always"
}
]
},
};
}
}
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ updates:
interval: daily
time: "02:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: "reflect-metadata"
update-types: ["version-update:semver-major"]
5 changes: 4 additions & 1 deletion .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ jobs:
- "8"
- "9"
- "10"
- "11"
nodejs-version:
- 18
- 20
- 22
include:
- nestjs-version: 8
typescript-version: 4
- nestjs-version: 9
typescript-version: 4
- nestjs-version: 10
typescript-version: 5
- nestjs-version: 11
typescript-version: 5

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
path: coverage
# restore cache from build-lint-test wf with key=sha-(oneof nestjs version)-(oneof nodejs version)
key: ${{ github.sha }}-10-20
key: ${{ github.sha }}-11-22

- uses: paambaati/[email protected]
with:
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<p align="center">
<img alt="War in Ukraine" src="https://raw.githubusercontent.com/iamolegga/nestjs-pino/master/war.jpg"/>
<br/>
Children wait in a bomb shelter in Mariupol, Ukraine. AP
<br/>
Help save their lives by donating:
<img alt="Bombed Vovchansk, Ukraine" src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Vovchansk_%282024-06-02%29_1513.jpg/640px-Vovchansk_%282024-06-02%29_1513.jpg"/>
<br />
<small>"Vovchansk (2024-06-02) 1513" by National Police of Ukraine (Liut Brigade) is licensed under CC BY 4.0.</small>
</p>
<p align="center">
This is Vovchansk, Ukraine, the city where the father of this library’s author was born. This is how it looks now, after the Russian invasion. If you find this library useful and would like to thank the author, please consider donating any amount via one of the following links:
<br/>
・<a href="https://war.ukraine.ua/donate/">Armed Forces of Ukraine</a>・<a href="https://www.comebackalive.in.ua/">Ukrainian volunteers</a>・
・<a href="https://war.ukraine.ua/donate/">Armed Forces of Ukraine</a>・<a href="https://savelife.in.ua/en/">"The Come Back Alive" foundation</a>・
<br/>
Thanks for your support!
Thanks for your support! 🇺🇦
</p>

<h1 align="center">NestJS-Pino</h1>
Expand Down
1 change: 1 addition & 0 deletions __tests__/module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Module, Controller, Get, Injectable, Logger } from '@nestjs/common';
// eslint-disable-next-line @typescript-eslint/no-require-imports
import MemoryStream = require('memorystream');

import { LoggerModule, Params } from '../src';
Expand Down
3 changes: 2 additions & 1 deletion __tests__/use-existing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Logger,
} from '@nestjs/common';
import { FastifyAdapter } from '@nestjs/platform-fastify';
// eslint-disable-next-line @typescript-eslint/no-require-imports
import MemoryStream = require('memorystream');
import pino from 'pino';

Expand Down Expand Up @@ -42,7 +43,7 @@ describe('useExisting property', () => {
}
}

await new TestCase(new FastifyAdapter({ logger: pino(stream) }), {
await new TestCase(new FastifyAdapter({ logger: { stream } }), {
controllers: [TestController],
providers: [TestService],
})
Expand Down
3 changes: 2 additions & 1 deletion __tests__/utils/test-case.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Module, ModuleMetadata, Type } from '@nestjs/common';
import { AbstractHttpAdapter, NestFactory } from '@nestjs/core';
// eslint-disable-next-line @typescript-eslint/no-require-imports
import MemoryStream = require('memorystream');
import pino from 'pino';
import { Options } from 'pino-http';
Expand Down Expand Up @@ -87,6 +87,7 @@ export class TestCase {
paths = ['/'];
}
expect(this.module).toBeTruthy();
if (!this.module) throw new Error();

__resetSingletons();

Expand Down
127 changes: 127 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["**/.eslintrc.js"],
}, ...fixupConfigRules(compat.extends(
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:prettier/recommended",
)), {
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslintEslintPlugin),
},

languageOptions: {
globals: {
...globals.node,
...globals.jest,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: "module",

parserOptions: {
project: "tsconfig.json",
},
},

rules: {
"@typescript-eslint/no-explicit-any": ["error", {
fixToUnknown: true,
ignoreRestArgs: false,
}],

"@typescript-eslint/no-floating-promises": ["error", {
ignoreIIFE: true,
}],

"@typescript-eslint/no-unused-vars": ["error", {
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
ignoreRestSiblings: true,
}],

"@typescript-eslint/explicit-member-accessibility": ["error", {
accessibility: "no-public",
}],

"@typescript-eslint/member-ordering": ["error", {
default: [
"public-static-field",
"public-static-get",
"public-static-set",
"public-static-method",
"protected-static-field",
"protected-static-get",
"protected-static-set",
"protected-static-method",
"private-static-field",
"private-static-get",
"private-static-set",
"private-static-method",
"signature",
"public-abstract-field",
"protected-abstract-field",
"public-decorated-field",
"public-instance-field",
"protected-decorated-field",
"protected-instance-field",
"private-decorated-field",
"private-instance-field",
"public-constructor",
"protected-constructor",
"private-constructor",
"public-abstract-get",
"public-abstract-set",
"public-abstract-method",
"public-decorated-get",
"public-instance-get",
"public-decorated-set",
"public-instance-set",
"public-decorated-method",
"public-instance-method",
"protected-abstract-get",
"protected-abstract-set",
"protected-abstract-method",
"protected-decorated-get",
"protected-instance-get",
"protected-decorated-set",
"protected-instance-set",
"protected-decorated-method",
"protected-instance-method",
"private-decorated-get",
"private-instance-get",
"private-decorated-set",
"private-instance-set",
"private-decorated-method",
"private-instance-method",
],
}],

"import/order": ["error", {
alphabetize: {
order: "asc",
caseInsensitive: true,
},

"newlines-between": "always",
}],
},
}];
Loading

0 comments on commit 1c3c3f7

Please sign in to comment.