-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2465 from nestjs/7.0.0
chore: laying the grounds for v7.0.0
- Loading branch information
Showing
25 changed files
with
819 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,23 @@ version: 2 | |
aliases: | ||
- &restore-cache | ||
restore_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
- &install-deps | ||
run: | ||
name: Install dependencies | ||
command: npm ci | ||
name: Install dependencies | ||
command: npm ci | ||
- &build-packages | ||
run: | ||
name: Build | ||
command: npm run build | ||
name: Build | ||
command: npm run build | ||
- &run-unit-tests | ||
run: | ||
name: Test | ||
command: npm run test -- --runInBand | ||
- &run-unit-tests | ||
run: | ||
name: Test (TypeScript < v4.8) | ||
command: npm i --no-save -D [email protected] && npm run test -- --runInBand | ||
name: Test | ||
command: npm run test -- --runInBand | ||
- &run-e2e-tests | ||
run: | ||
name: E2E test | ||
command: npm run test:e2e | ||
name: E2E test | ||
command: npm run test:e2e | ||
|
||
jobs: | ||
build: | ||
|
@@ -46,7 +42,7 @@ jobs: | |
- ./node_modules | ||
- run: | ||
name: Build | ||
command: npm run build | ||
command: npm run build | ||
|
||
unit_tests: | ||
working_directory: ~/nest | ||
|
@@ -81,4 +77,3 @@ workflows: | |
- e2e_tests: | ||
requires: | ||
- build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
import { Type } from '@nestjs/common'; | ||
import { DECORATORS } from '../constants'; | ||
import { ApiOperation } from '../decorators/api-operation.decorator'; | ||
import { METADATA_FACTORY_NAME } from '../plugin/plugin-constants'; | ||
|
||
export const exploreApiOperationMetadata = ( | ||
instance: object, | ||
prototype: Type<unknown>, | ||
method: object | ||
) => Reflect.getMetadata(DECORATORS.API_OPERATION, method); | ||
) => { | ||
applyMetadataFactory(prototype); | ||
return Reflect.getMetadata(DECORATORS.API_OPERATION, method); | ||
}; | ||
|
||
function applyMetadataFactory(prototype: Type<unknown>) { | ||
const classPrototype = prototype; | ||
do { | ||
if (!prototype.constructor) { | ||
return; | ||
} | ||
if (!prototype.constructor[METADATA_FACTORY_NAME]) { | ||
continue; | ||
} | ||
const metadata = prototype.constructor[METADATA_FACTORY_NAME](); | ||
const methodKeys = Object.keys(metadata); | ||
methodKeys.forEach((key) => { | ||
const operationMeta = {}; | ||
const { summary, deprecated, tags } = metadata[key]; | ||
|
||
applyIfNotNil(operationMeta, 'summary', summary); | ||
applyIfNotNil(operationMeta, 'deprecated', deprecated); | ||
applyIfNotNil(operationMeta, 'tags', tags); | ||
|
||
if (Object.keys(operationMeta).length === 0) { | ||
return; | ||
} | ||
ApiOperation(operationMeta, { overrideExisting: false })( | ||
classPrototype, | ||
key, | ||
Object.getOwnPropertyDescriptor(classPrototype, key) | ||
); | ||
}); | ||
} while ( | ||
(prototype = Reflect.getPrototypeOf(prototype) as Type<any>) && | ||
prototype !== Object.prototype && | ||
prototype | ||
); | ||
} | ||
|
||
function applyIfNotNil(target: Record<string, any>, key: string, value: any) { | ||
if (value !== undefined && value !== null) { | ||
target[key] = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.