mirror of
https://github.com/nestjs/nest.git
synced 2026-02-23 15:52:50 +00:00
Compare commits
284 Commits
v7.6.5
...
andrewda-h
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4804f32472 | ||
|
|
40a0678fbf | ||
|
|
6b119c3579 | ||
|
|
f22d3370f3 | ||
|
|
c12100c3c6 | ||
|
|
8cf29c9172 | ||
|
|
12ac1108a7 | ||
|
|
c150deefbd | ||
|
|
68b5d2a8e2 | ||
|
|
4d87dd6b1e | ||
|
|
e0b825121b | ||
|
|
dc8b1d5c72 | ||
|
|
832b3bc90c | ||
|
|
8180e5905c | ||
|
|
2307373bfe | ||
|
|
71255392c9 | ||
|
|
07c8cdc80b | ||
|
|
f9e5272e2b | ||
|
|
b842a7e817 | ||
|
|
8df890a8ac | ||
|
|
060befe22e | ||
|
|
06bddccb5c | ||
|
|
4f88c3d147 | ||
|
|
dd7c176df3 | ||
|
|
c43fb62322 | ||
|
|
8c4fb929b7 | ||
|
|
1130edc150 | ||
|
|
6417c5477a | ||
|
|
149483a852 | ||
|
|
27d9202108 | ||
|
|
950e3697c7 | ||
|
|
df5a7c3a48 | ||
|
|
25b7ad5805 | ||
|
|
0f668075fb | ||
|
|
b74f80fb1c | ||
|
|
a0d08f049c | ||
|
|
c88db600a0 | ||
|
|
e196f51608 | ||
|
|
f4c45f8d88 | ||
|
|
4baea48cfa | ||
|
|
275e71f89a | ||
|
|
4a1074a793 | ||
|
|
e9d1735688 | ||
|
|
3b93861706 | ||
|
|
6d1c02be01 | ||
|
|
1e5f60ed17 | ||
|
|
6379162871 | ||
|
|
fddc980b1d | ||
|
|
6027001b4e | ||
|
|
0cd83570a2 | ||
|
|
48d91c9646 | ||
|
|
9b9b3564a4 | ||
|
|
25526070a1 | ||
|
|
6df1712b0d | ||
|
|
8aa0f75c8c | ||
|
|
c0babd6cfd | ||
|
|
6448d17f43 | ||
|
|
6a9c9100f5 | ||
|
|
55c7051787 | ||
|
|
db6a555d29 | ||
|
|
7c722c3d0b | ||
|
|
e7011e3b4f | ||
|
|
0fb8e1a025 | ||
|
|
459458bbb4 | ||
|
|
9e96e76e1a | ||
|
|
a63db1b8aa | ||
|
|
477b6d0d5c | ||
|
|
90aa625bf8 | ||
|
|
e8541185f0 | ||
|
|
c48e2bcfdb | ||
|
|
667df81eb5 | ||
|
|
fb5117c241 | ||
|
|
ec9727093d | ||
|
|
d2e6616115 | ||
|
|
9f3614042f | ||
|
|
2bc2c8adfa | ||
|
|
e4c5d17df2 | ||
|
|
bf420cd91d | ||
|
|
5d48691713 | ||
|
|
454d519c67 | ||
|
|
60f256ecdf | ||
|
|
df4c2eb318 | ||
|
|
843116eea9 | ||
|
|
3af5404401 | ||
|
|
9a6610cb07 | ||
|
|
a76a6e4a30 | ||
|
|
d063c4772d | ||
|
|
64d78a9c80 | ||
|
|
efe4884c27 | ||
|
|
5ebd3353b1 | ||
|
|
5d2fa36556 | ||
|
|
1440ccaa4b | ||
|
|
42262df197 | ||
|
|
6f119c843c | ||
|
|
cb0564d77a | ||
|
|
d28c25618d | ||
|
|
4a57915f5a | ||
|
|
3188b801bd | ||
|
|
b7e46f45d4 | ||
|
|
993e5f4a91 | ||
|
|
bc394eabb2 | ||
|
|
0b874e7dfc | ||
|
|
a65fcd1472 | ||
|
|
159cdce1f1 | ||
|
|
b298b8bc92 | ||
|
|
53226211f7 | ||
|
|
d4bb87c5eb | ||
|
|
fa4642f70f | ||
|
|
c4c1b7c6a5 | ||
|
|
2be4c4cd70 | ||
|
|
76289893d7 | ||
|
|
b3e654e84d | ||
|
|
668d781b6c | ||
|
|
fb45437621 | ||
|
|
0c7bf92086 | ||
|
|
091d09fde2 | ||
|
|
653f0a4281 | ||
|
|
48d899d025 | ||
|
|
81f3161f7c | ||
|
|
0f29446c65 | ||
|
|
1b31a744a8 | ||
|
|
0fe31b9bc8 | ||
|
|
5da5a4ad58 | ||
|
|
2abb9b2154 | ||
|
|
43f053ab21 | ||
|
|
a74725d585 | ||
|
|
51f5de8333 | ||
|
|
0c8b004bf9 | ||
|
|
3ce92c7883 | ||
|
|
3bbde4c26c | ||
|
|
a48107ef92 | ||
|
|
b7990aa5b1 | ||
|
|
07737aa371 | ||
|
|
ca7b79532f | ||
|
|
ad6ce62f0e | ||
|
|
4c814a2d85 | ||
|
|
1dbb8ff3db | ||
|
|
c6780a3a91 | ||
|
|
1945f8d24a | ||
|
|
ccd4fdae58 | ||
|
|
817d9f45e0 | ||
|
|
9362db8042 | ||
|
|
2fb5f4dd16 | ||
|
|
a400be366b | ||
|
|
7267409d91 | ||
|
|
fa494041c8 | ||
|
|
af4f041d6a | ||
|
|
562b2bb175 | ||
|
|
36c2a35614 | ||
|
|
fb4cc36c75 | ||
|
|
7386204da6 | ||
|
|
d99370bb1d | ||
|
|
90fcd3599e | ||
|
|
e3a66d1902 | ||
|
|
71cab143e6 | ||
|
|
3357fe0349 | ||
|
|
be0cdfe7e6 | ||
|
|
c9c92b47de | ||
|
|
6fb25e93e2 | ||
|
|
6957b52afe | ||
|
|
5b7eae83e0 | ||
|
|
52546cc62e | ||
|
|
d43c4d7510 | ||
|
|
b4c24cc17e | ||
|
|
119190ad75 | ||
|
|
3361cfd236 | ||
|
|
0cf4409869 | ||
|
|
5028393d57 | ||
|
|
05b771a9c2 | ||
|
|
d972d9ad8f | ||
|
|
668968faa9 | ||
|
|
d588b8bc68 | ||
|
|
1a0922a58b | ||
|
|
cd04a8d58a | ||
|
|
ff935dac06 | ||
|
|
ba2f5ae63a | ||
|
|
0d67f823d5 | ||
|
|
f001a9ab83 | ||
|
|
8bc4e92d21 | ||
|
|
d2d951870c | ||
|
|
29e158ac66 | ||
|
|
29192b38e4 | ||
|
|
e6e11b9cf1 | ||
|
|
38974dc290 | ||
|
|
8b86d836c3 | ||
|
|
967206ca5d | ||
|
|
ca830a8519 | ||
|
|
ce28bee865 | ||
|
|
9e20b0a858 | ||
|
|
b60691737f | ||
|
|
41415b5b91 | ||
|
|
65d2fac038 | ||
|
|
fe0b7bc95b | ||
|
|
b876a5542c | ||
|
|
b14c7de30b | ||
|
|
439512a748 | ||
|
|
fa0024e581 | ||
|
|
854522eb88 | ||
|
|
3f67e9a0f2 | ||
|
|
b5a92dd1be | ||
|
|
9c15dc692d | ||
|
|
7efeba63c6 | ||
|
|
1db29b3632 | ||
|
|
32d06a2bea | ||
|
|
a04d19b339 | ||
|
|
27e1748ae9 | ||
|
|
025fb6bae9 | ||
|
|
d7fafd59ab | ||
|
|
54514b636b | ||
|
|
b0de6b20c7 | ||
|
|
d13fad341a | ||
|
|
ad955270cf | ||
|
|
7f300dc640 | ||
|
|
06b220fd92 | ||
|
|
d823d9bf75 | ||
|
|
a58db3a89d | ||
|
|
3b8e4172e7 | ||
|
|
6cd9b7e6d4 | ||
|
|
989582529b | ||
|
|
5210db3050 | ||
|
|
ae76f46e3c | ||
|
|
9c102342d9 | ||
|
|
7e79847c61 | ||
|
|
da4fc69e2b | ||
|
|
25b6e501f8 | ||
|
|
1f4f8222b1 | ||
|
|
a85cd23088 | ||
|
|
b0cc4a2ec5 | ||
|
|
e235bcfcd5 | ||
|
|
4841d48e93 | ||
|
|
dac636f0c1 | ||
|
|
dfefa63697 | ||
|
|
30e90b7a3a | ||
|
|
045983d7aa | ||
|
|
660be0ed86 | ||
|
|
c523845855 | ||
|
|
d560888761 | ||
|
|
fdd678c013 | ||
|
|
4950c53586 | ||
|
|
57ebb8e04e | ||
|
|
e77b185828 | ||
|
|
bc74ef28a3 | ||
|
|
9e6667f9e8 | ||
|
|
d74ae63e83 | ||
|
|
a4c475ddc2 | ||
|
|
aa4c8608ed | ||
|
|
13b366878e | ||
|
|
c6bf80f76c | ||
|
|
3080f75534 | ||
|
|
766218aad1 | ||
|
|
d6b2266615 | ||
|
|
344f6a6efc | ||
|
|
9421dae875 | ||
|
|
27dafd8292 | ||
|
|
5150334252 | ||
|
|
6f9ae1c871 | ||
|
|
65c6c443a6 | ||
|
|
732d378c62 | ||
|
|
55033eb6b4 | ||
|
|
5f103779b4 | ||
|
|
2753474871 | ||
|
|
aeec26c25a | ||
|
|
55d7542cb1 | ||
|
|
987faa5f2e | ||
|
|
c5aa2c7b01 | ||
|
|
73059b574f | ||
|
|
98c9674b26 | ||
|
|
a1c76b4a7e | ||
|
|
eabc87063e | ||
|
|
562cd3d6ee | ||
|
|
4b35074d5c | ||
|
|
287b8a4371 | ||
|
|
b627789e7e | ||
|
|
c313e14add | ||
|
|
a0a2aeba77 | ||
|
|
a2c6cb3ef9 | ||
|
|
86051702b8 | ||
|
|
dd51cf8f51 | ||
|
|
525ef91307 | ||
|
|
7dad2e479b | ||
|
|
530274e2c8 | ||
|
|
d24d0381a2 | ||
|
|
85dcf72508 | ||
|
|
f4df4d9a9e |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2017-2020 Kamil Mysliwiec <https://kamilmysliwiec.com>
|
||||
Copyright (c) 2017-2021 Kamil Mysliwiec <https://kamilmysliwiec.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
16
Readme.md
16
Readme.md
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
177
integration/cors/e2e/express.spec.ts
Normal file
177
integration/cors/e2e/express.spec.ts
Normal file
@@ -0,0 +1,177 @@
|
||||
import { NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
|
||||
describe('Express Cors', () => {
|
||||
let app: NestFastifyApplication;
|
||||
const configs = [
|
||||
{
|
||||
origin: 'example.com',
|
||||
methods: 'GET',
|
||||
credentials: true,
|
||||
exposedHeaders: ['foo', 'bar'],
|
||||
allowedHeaders: ['baz', 'woo'],
|
||||
maxAge: 123,
|
||||
},
|
||||
{
|
||||
origin: 'sample.com',
|
||||
methods: 'GET',
|
||||
credentials: true,
|
||||
exposedHeaders: ['zoo', 'bar'],
|
||||
allowedHeaders: ['baz', 'foo'],
|
||||
maxAge: 321,
|
||||
},
|
||||
];
|
||||
describe('Dynamic config', () => {
|
||||
describe('enableCors', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>();
|
||||
|
||||
let requestId = 0;
|
||||
const configDelegation = function (req, cb) {
|
||||
const config = configs[requestId];
|
||||
requestId++;
|
||||
cb(null, config);
|
||||
};
|
||||
app.enableCors(configDelegation);
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the first config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the second config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.options('/')
|
||||
.expect('access-control-allow-origin', 'sample.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'zoo,bar')
|
||||
.expect('access-control-allow-methods', 'GET')
|
||||
.expect('access-control-allow-headers', 'baz,foo')
|
||||
.expect('access-control-max-age', '321')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Application Options', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
let requestId = 0;
|
||||
const configDelegation = function (req, cb) {
|
||||
const config = configs[requestId];
|
||||
requestId++;
|
||||
cb(null, config);
|
||||
};
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>(null, {
|
||||
cors: configDelegation,
|
||||
});
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the first config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the second config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.options('/')
|
||||
.expect('access-control-allow-origin', 'sample.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'zoo,bar')
|
||||
.expect('access-control-allow-methods', 'GET')
|
||||
.expect('access-control-allow-headers', 'baz,foo')
|
||||
.expect('access-control-max-age', '321')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('Static config', () => {
|
||||
describe('enableCors', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>();
|
||||
app.enableCors(configs[0]);
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`CORS headers`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
describe('Application Options', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>(null, {
|
||||
cors: configs[0],
|
||||
});
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`CORS headers`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
177
integration/cors/e2e/fastify.spec.ts
Normal file
177
integration/cors/e2e/fastify.spec.ts
Normal file
@@ -0,0 +1,177 @@
|
||||
import { NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
|
||||
describe('Fastify Cors', () => {
|
||||
let app: NestFastifyApplication;
|
||||
const configs = [
|
||||
{
|
||||
origin: 'example.com',
|
||||
methods: 'GET',
|
||||
credentials: true,
|
||||
exposedHeaders: ['foo', 'bar'],
|
||||
allowedHeaders: ['baz', 'woo'],
|
||||
maxAge: 123,
|
||||
},
|
||||
{
|
||||
origin: 'sample.com',
|
||||
methods: 'GET',
|
||||
credentials: true,
|
||||
exposedHeaders: ['zoo', 'bar'],
|
||||
allowedHeaders: ['baz', 'foo'],
|
||||
maxAge: 321,
|
||||
},
|
||||
];
|
||||
describe('Dynamic config', () => {
|
||||
describe('enableCors', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>();
|
||||
|
||||
let requestId = 0;
|
||||
const configDelegation = function (req, cb) {
|
||||
const config = configs[requestId];
|
||||
requestId++;
|
||||
cb(null, config);
|
||||
};
|
||||
app.enableCors(configDelegation);
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the first config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the second config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.options('/')
|
||||
.expect('access-control-allow-origin', 'sample.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'zoo,bar')
|
||||
.expect('access-control-allow-methods', 'GET')
|
||||
.expect('access-control-allow-headers', 'baz,foo')
|
||||
.expect('access-control-max-age', '321')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Application Options', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
let requestId = 0;
|
||||
const configDelegation = function (req, cb) {
|
||||
const config = configs[requestId];
|
||||
requestId++;
|
||||
cb(null, config);
|
||||
};
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>(null, {
|
||||
cors: configDelegation,
|
||||
});
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the first config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
it(`Should add cors headers based on the second config`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.options('/')
|
||||
.expect('access-control-allow-origin', 'sample.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'zoo,bar')
|
||||
.expect('access-control-allow-methods', 'GET')
|
||||
.expect('access-control-allow-headers', 'baz,foo')
|
||||
.expect('access-control-max-age', '321')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Static config', () => {
|
||||
describe('enableCors', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>();
|
||||
app.enableCors(configs[0]);
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`CORS headers`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
describe('Application Options', () => {
|
||||
before(async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication<NestFastifyApplication>(null, {
|
||||
cors: configs[0],
|
||||
});
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it(`CORS headers`, async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect('access-control-allow-origin', 'example.com')
|
||||
.expect('vary', 'Origin')
|
||||
.expect('access-control-allow-credentials', 'true')
|
||||
.expect('access-control-expose-headers', 'foo,bar')
|
||||
.expect('content-length', '0');
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
9
integration/cors/src/app.controller.ts
Normal file
9
integration/cors/src/app.controller.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
@Get()
|
||||
getGlobals() {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
7
integration/cors/src/app.module.ts
Normal file
7
integration/cors/src/app.module.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [AppController],
|
||||
})
|
||||
export class AppModule {}
|
||||
22
integration/cors/tsconfig.json
Normal file
22
integration/cors/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es6",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"e2e/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
]
|
||||
}
|
||||
@@ -23,7 +23,7 @@ services:
|
||||
- "9001:9001"
|
||||
restart: always
|
||||
mysql:
|
||||
image: mysql:5.7.32
|
||||
image: mysql:5.7.33
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: test
|
||||
|
||||
@@ -63,6 +63,22 @@ describe('Hello world (fastify adapter)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it(`/GET { host: [":tenant.example1.com", ":tenant.example2.com"] } not matched`, () => {
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/host-array',
|
||||
})
|
||||
.then(({ payload }) => {
|
||||
expect(JSON.parse(payload)).to.be.eql({
|
||||
error: 'Internal Server Error',
|
||||
message:
|
||||
'HTTP adapter does not support filtering on hosts: [":tenant.example1.com", ":tenant.example2.com"]',
|
||||
statusCode: 500,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it(`/GET inject with LightMyRequest chaining API`, () => {
|
||||
return app
|
||||
.inject()
|
||||
|
||||
@@ -28,6 +28,16 @@ describe('Hello world (default adapter)', () => {
|
||||
path: '/host',
|
||||
greeting: 'Host Greeting! tenant=acme',
|
||||
},
|
||||
{
|
||||
host: 'acme.example1.com',
|
||||
path: '/host-array',
|
||||
greeting: 'Host Greeting! tenant=acme',
|
||||
},
|
||||
{
|
||||
host: 'acme.example2.com',
|
||||
path: '/host-array',
|
||||
greeting: 'Host Greeting! tenant=acme',
|
||||
},
|
||||
].forEach(({ host, path, greeting }) => {
|
||||
describe(`host=${host}`, () => {
|
||||
describe('/GET', () => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { HelloModule } from './hello/hello.module';
|
||||
import { HostArrayModule } from './host-array/host-array.module';
|
||||
import { HostModule } from './host/host.module';
|
||||
|
||||
@Module({
|
||||
imports: [HelloModule, HostModule],
|
||||
imports: [HelloModule, HostModule, HostArrayModule],
|
||||
})
|
||||
export class ApplicationModule {}
|
||||
|
||||
10
integration/hello-world/src/host-array/dto/test.dto.ts
Normal file
10
integration/hello-world/src/host-array/dto/test.dto.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
|
||||
|
||||
export class TestDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
string: string;
|
||||
|
||||
@IsNumber()
|
||||
number: number;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Controller, Get, Header, HostParam, Param } from '@nestjs/common';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { HostArrayService } from './host-array.service';
|
||||
import { UserByIdPipe } from './users/user-by-id.pipe';
|
||||
|
||||
@Controller({
|
||||
path: 'host-array',
|
||||
host: [':tenant.example1.com', ':tenant.example2.com'],
|
||||
})
|
||||
export class HostArrayController {
|
||||
constructor(private readonly hostService: HostArrayService) {}
|
||||
|
||||
@Get()
|
||||
@Header('Authorization', 'Bearer')
|
||||
greeting(@HostParam('tenant') tenant: string): string {
|
||||
return `${this.hostService.greeting()} tenant=${tenant}`;
|
||||
}
|
||||
|
||||
@Get('async')
|
||||
async asyncGreeting(@HostParam('tenant') tenant: string): Promise<string> {
|
||||
return `${await this.hostService.greeting()} tenant=${tenant}`;
|
||||
}
|
||||
|
||||
@Get('stream')
|
||||
streamGreeting(@HostParam('tenant') tenant: string): Observable<string> {
|
||||
return of(`${this.hostService.greeting()} tenant=${tenant}`);
|
||||
}
|
||||
|
||||
@Get('local-pipe/:id')
|
||||
localPipe(
|
||||
@Param('id', UserByIdPipe)
|
||||
user: any,
|
||||
@HostParam('tenant') tenant: string,
|
||||
): any {
|
||||
return { ...user, tenant };
|
||||
}
|
||||
}
|
||||
10
integration/hello-world/src/host-array/host-array.module.ts
Normal file
10
integration/hello-world/src/host-array/host-array.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { HostArrayController } from './host-array.controller';
|
||||
import { HostArrayService } from './host-array.service';
|
||||
import { UsersService } from './users/users.service';
|
||||
|
||||
@Module({
|
||||
controllers: [HostArrayController],
|
||||
providers: [HostArrayService, UsersService],
|
||||
})
|
||||
export class HostArrayModule {}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class HostArrayService {
|
||||
greeting(): string {
|
||||
return 'Host Greeting!';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { PipeTransform, Injectable, ArgumentMetadata } from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
@Injectable()
|
||||
export class UserByIdPipe implements PipeTransform<string> {
|
||||
constructor(private readonly usersService: UsersService) {}
|
||||
|
||||
transform(value: string, metadata: ArgumentMetadata) {
|
||||
return this.usersService.findById(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
findById(id: string) {
|
||||
return { id, host: true };
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,22 @@ describe('RPC transport', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('/POST (custom client)', () => {
|
||||
return request(server)
|
||||
.post('/error?client=custom')
|
||||
.send({})
|
||||
.expect(200)
|
||||
.expect('true');
|
||||
});
|
||||
|
||||
it('/POST (standard client)', () => {
|
||||
return request(server)
|
||||
.post('/error?client=standard')
|
||||
.send({})
|
||||
.expect(200)
|
||||
.expect('false');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
@@ -12,15 +12,17 @@ import {
|
||||
EventPattern,
|
||||
MessagePattern,
|
||||
Transport,
|
||||
RpcException,
|
||||
} from '@nestjs/microservices';
|
||||
import { from, Observable, of } from 'rxjs';
|
||||
import { scan } from 'rxjs/operators';
|
||||
import { from, Observable, of, throwError } from 'rxjs';
|
||||
import { catchError, scan } from 'rxjs/operators';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(
|
||||
@Inject('USE_CLASS_CLIENT') private useClassClient: ClientProxy,
|
||||
@Inject('USE_FACTORY_CLIENT') private useFactoryClient: ClientProxy,
|
||||
@Inject('CUSTOM_PROXY_CLIENT') private customClient: ClientProxy,
|
||||
) {}
|
||||
static IS_NOTIFIED = false;
|
||||
|
||||
@@ -75,6 +77,17 @@ export class AppController {
|
||||
.reduce(async (a, b) => (await a) && b);
|
||||
}
|
||||
|
||||
@Post('error')
|
||||
@HttpCode(200)
|
||||
serializeError(@Query('client') query: 'custom' | 'standard' = 'standard', @Body() body: Record<string, any>): Observable<boolean> {
|
||||
const client = query === 'custom' ? this.customClient : this.client;
|
||||
return client.send({ cmd: 'err' }, {}).pipe(
|
||||
catchError((err) => {
|
||||
return of(err instanceof RpcException);
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'sum' })
|
||||
sum(data: number[]): number {
|
||||
return (data || []).reduce((a, b) => a + b);
|
||||
@@ -95,6 +108,11 @@ export class AppController {
|
||||
return from(data);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'err' })
|
||||
throwAnError() {
|
||||
return throwError(new Error('err'));
|
||||
}
|
||||
|
||||
@Post('notify')
|
||||
async sendNotification(): Promise<any> {
|
||||
return this.client.emit<number>('notification', true);
|
||||
|
||||
@@ -5,8 +5,16 @@ import {
|
||||
Transport,
|
||||
ClientsModuleOptionsFactory,
|
||||
ClientOptions,
|
||||
ClientTCP,
|
||||
RpcException,
|
||||
} from '@nestjs/microservices';
|
||||
|
||||
class ErrorHandlingProxy extends ClientTCP {
|
||||
serializeError(err) {
|
||||
return new RpcException(err);
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
class ConfigService {
|
||||
private readonly config = {
|
||||
@@ -51,7 +59,14 @@ class ClientOptionService implements ClientsModuleOptionsFactory {
|
||||
name: 'USE_CLASS_CLIENT',
|
||||
useClass: ClientOptionService,
|
||||
inject: [ConfigService],
|
||||
},
|
||||
}, {
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
name: 'CUSTOM_PROXY_CLIENT',
|
||||
useFactory: (config: ConfigService) => ({
|
||||
customClass: ErrorHandlingProxy
|
||||
})
|
||||
}
|
||||
]),
|
||||
],
|
||||
controllers: [AppController],
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { Body, Controller, HttpCode, OnModuleInit, Post, OnModuleDestroy } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
HttpCode,
|
||||
OnModuleInit,
|
||||
Post,
|
||||
OnModuleDestroy,
|
||||
} from '@nestjs/common';
|
||||
import { Logger } from '@nestjs/common/services/logger.service';
|
||||
import { Client, ClientKafka, Transport } from '@nestjs/microservices';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "7.6.5"
|
||||
"version": "7.6.8"
|
||||
}
|
||||
|
||||
35598
package-lock.json
generated
35598
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
77
package.json
77
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/core",
|
||||
"version": "7.5.3",
|
||||
"version": "7.6.8",
|
||||
"description": "Modern, fast, powerful node.js web framework",
|
||||
"homepage": "https://nestjs.com",
|
||||
"repository": {
|
||||
@@ -29,9 +29,10 @@
|
||||
"test:docker:up": "docker-compose -f integration/docker-compose.yml up -d",
|
||||
"test:docker:down": "docker-compose -f integration/docker-compose.yml down",
|
||||
"lint": "concurrently 'npm run lint:packages' 'npm run lint:integration' 'npm run lint:spec'",
|
||||
"lint:integration": "eslint 'integration/*/{,!(node_modules)/**/}/*.ts' -c '.eslintrc.spec.js' --fix",
|
||||
"lint:packages": "eslint 'packages/**/**.ts' --fix --ignore-pattern 'packages/**/*.spec.ts'",
|
||||
"lint:spec": "eslint 'packages/**/**.spec.ts' -c '.eslintrc.spec.js' --fix",
|
||||
"lint:fix": "concurrently 'npm run lint:packages -- --fix' 'npm run lint:integration -- --fix' 'npm run lint:spec -- --fix'",
|
||||
"lint:integration": "eslint 'integration/*/{,!(node_modules)/**/}/*.ts' -c '.eslintrc.spec.js'",
|
||||
"lint:packages": "eslint 'packages/**/**.ts' --ignore-pattern 'packages/**/*.spec.ts'",
|
||||
"lint:spec": "eslint 'packages/**/**.spec.ts' -c '.eslintrc.spec.js'",
|
||||
"prerelease": "gulp copy-misc && gulp build --dist node_modules/@nestjs",
|
||||
"publish": "npm run prerelease && npm run build:prod && ./node_modules/.bin/lerna publish --force-publish --access public --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
"publish:beta": "npm run prerelease && npm run build:prod && ./node_modules/.bin/lerna publish --npm-tag=beta --access public -m \"chore(@nestjs) publish %s release\"",
|
||||
@@ -53,51 +54,51 @@
|
||||
"dependencies": {
|
||||
"@nuxtjs/opencollective": "0.3.2",
|
||||
"axios": "0.21.1",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"cli-color": "2.0.0",
|
||||
"cors": "2.8.5",
|
||||
"express": "4.17.1",
|
||||
"fast-json-stringify": "2.3.0",
|
||||
"fast-json-stringify": "2.4.1",
|
||||
"fast-safe-stringify": "2.0.7",
|
||||
"iterare": "1.2.1",
|
||||
"object-hash": "2.1.1",
|
||||
"path-to-regexp": "3.2.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.6.3",
|
||||
"socket.io": "2.3.0",
|
||||
"tslib": "2.0.3",
|
||||
"socket.io": "2.4.1",
|
||||
"tslib": "2.1.0",
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codechecks/client": "0.1.10",
|
||||
"@commitlint/cli": "11.0.0",
|
||||
"@commitlint/config-angular": "11.0.0",
|
||||
"@grpc/proto-loader": "0.5.5",
|
||||
"@nestjs/graphql": "7.9.2",
|
||||
"@nestjs/mongoose": "7.2.0",
|
||||
"@grpc/proto-loader": "0.5.6",
|
||||
"@nestjs/graphql": "7.9.8",
|
||||
"@nestjs/mongoose": "7.2.2",
|
||||
"@nestjs/typeorm": "7.1.5",
|
||||
"@types/amqplib": "0.5.17",
|
||||
"@types/bytes": "3.1.0",
|
||||
"@types/cache-manager": "2.10.3",
|
||||
"@types/cache-manager": "3.4.0",
|
||||
"@types/chai": "4.2.14",
|
||||
"@types/chai-as-promised": "7.1.3",
|
||||
"@types/cors": "2.8.9",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/gulp": "4.0.7",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/gulp": "4.0.8",
|
||||
"@types/mocha": "8.2.0",
|
||||
"@types/mongoose": "5.10.3",
|
||||
"@types/node": "14.14.16",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/redis": "2.8.28",
|
||||
"@types/reflect-metadata": "0.1.0",
|
||||
"@types/sinon": "9.0.10",
|
||||
"@types/socket.io": "2.1.12",
|
||||
"@types/socket.io": "2.1.13",
|
||||
"@types/ws": "7.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.1",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"amqp-connection-manager": "3.2.1",
|
||||
"amqplib": "0.6.0",
|
||||
"apollo-server-express": "2.19.1",
|
||||
"apollo-server-express": "2.19.2",
|
||||
"artillery": "1.6.1",
|
||||
"awesome-typescript-loader": "5.2.1",
|
||||
"body-parser": "1.19.0",
|
||||
@@ -109,21 +110,21 @@
|
||||
"commitlint-circle": "1.0.0",
|
||||
"concurrently": "5.3.0",
|
||||
"conventional-changelog": "3.1.24",
|
||||
"core-js": "3.8.1",
|
||||
"core-js": "3.8.3",
|
||||
"coveralls": "3.1.0",
|
||||
"delete-empty": "3.0.0",
|
||||
"engine.io-client": "4.0.5",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"engine.io-client": "4.1.0",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"eventsource": "1.0.7",
|
||||
"fancy-log": "1.3.3",
|
||||
"fastify": "3.9.2",
|
||||
"fastify-cors": "5.1.0",
|
||||
"fastify": "3.11.0",
|
||||
"fastify-cors": "5.2.0",
|
||||
"fastify-formbody": "5.0.0",
|
||||
"fastify-multipart": "3.3.1",
|
||||
"fastify-static": "3.3.0",
|
||||
"graphql": "15.4.0",
|
||||
"fastify-static": "3.4.0",
|
||||
"graphql": "15.5.0",
|
||||
"graphql-tools": "7.0.2",
|
||||
"grpc": "1.24.4",
|
||||
"gulp": "4.0.2",
|
||||
@@ -132,8 +133,8 @@
|
||||
"gulp-sourcemaps": "3.0.0",
|
||||
"gulp-typescript": "5.0.1",
|
||||
"gulp-watch": "5.0.1",
|
||||
"husky": "4.3.6",
|
||||
"imports-loader": "1.2.0",
|
||||
"husky": "4.3.8",
|
||||
"imports-loader": "2.0.0",
|
||||
"json-loader": "0.5.7",
|
||||
"kafkajs": "1.15.0",
|
||||
"lerna": "2.11.0",
|
||||
@@ -143,28 +144,28 @@
|
||||
"merge-graphql-schemas": "1.7.8",
|
||||
"middie": "5.2.0",
|
||||
"mocha": "8.2.1",
|
||||
"mongoose": "5.11.9",
|
||||
"mongoose": "5.11.14",
|
||||
"mqtt": "4.2.6",
|
||||
"multer": "1.4.2",
|
||||
"mysql": "2.18.1",
|
||||
"nats": "1.4.12",
|
||||
"nodemon": "2.0.6",
|
||||
"nodemon": "2.0.7",
|
||||
"nyc": "15.1.0",
|
||||
"point-of-view": "4.7.0",
|
||||
"point-of-view": "4.11.0",
|
||||
"prettier": "2.2.1",
|
||||
"redis": "3.0.2",
|
||||
"rxjs-compat": "6.6.3",
|
||||
"sinon": "9.2.2",
|
||||
"sinon": "9.2.4",
|
||||
"sinon-chai": "3.5.0",
|
||||
"socket.io-client": "2.3.1",
|
||||
"socket.io-client": "2.4.0",
|
||||
"subscriptions-transport-ws": "0.9.18",
|
||||
"supertest": "6.0.1",
|
||||
"supertest": "6.1.3",
|
||||
"ts-morph": "9.1.0",
|
||||
"ts-node": "9.1.1",
|
||||
"typeorm": "0.2.29",
|
||||
"typeorm": "0.2.30",
|
||||
"typescript": "4.1.3",
|
||||
"wrk": "1.2.1",
|
||||
"ws": "7.4.1"
|
||||
"ws": "7.4.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.13.0"
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface ControllerOptions extends ScopeOptions {
|
||||
*
|
||||
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
||||
*/
|
||||
host?: string;
|
||||
host?: string | string[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,4 +78,3 @@ export class HttpException extends Error {
|
||||
: { statusCode, message: objectOrError, error: description };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,4 +50,9 @@ export interface ClassTransformOptions {
|
||||
* and exposing all class properties (with undefined, if nothing else is given)
|
||||
*/
|
||||
excludeExtraneousValues?: boolean;
|
||||
/**
|
||||
* If set to true then class transformer will take default values for unprovided fields.
|
||||
* This is useful when you convert a plain object to a class and have an optional field with a default value.
|
||||
*/
|
||||
exposeDefaultValues?: boolean;
|
||||
}
|
||||
|
||||
@@ -52,3 +52,10 @@ export interface CorsOptions {
|
||||
*/
|
||||
optionsSuccessStatus?: number;
|
||||
}
|
||||
|
||||
export interface CorsOptionsCallback {
|
||||
(error: Error, options: CorsOptions): void;
|
||||
}
|
||||
export interface CorsOptionsDelegate<T> {
|
||||
(req: T, cb: CorsOptionsCallback): void;
|
||||
}
|
||||
|
||||
@@ -2,29 +2,41 @@
|
||||
* Validation error description.
|
||||
* @see https://github.com/typestack/class-validator
|
||||
*
|
||||
* class-validator@0.13.0
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface ValidationError {
|
||||
/**
|
||||
* Object that was validated.
|
||||
*
|
||||
* OPTIONAL - configurable via the ValidatorOptions.validationError.target option
|
||||
*/
|
||||
target: Record<string, any>;
|
||||
target?: Record<string, any>;
|
||||
/**
|
||||
* Object's property that hasn't passed validation.
|
||||
*/
|
||||
property: string;
|
||||
/**
|
||||
* Value that hasn't passed validation.
|
||||
* Value that haven't pass a validation.
|
||||
*
|
||||
* OPTIONAL - configurable via the ValidatorOptions.validationError.value option
|
||||
*/
|
||||
value: any;
|
||||
value?: any;
|
||||
/**
|
||||
* Constraints that failed validation with error messages.
|
||||
*/
|
||||
constraints: {
|
||||
constraints?: {
|
||||
[type: string]: string;
|
||||
};
|
||||
/**
|
||||
* Contains all nested validation errors of the property.
|
||||
*/
|
||||
children: ValidationError[];
|
||||
children?: ValidationError[];
|
||||
/**
|
||||
* A transient set of data passed through to the validation result for response mapping
|
||||
*/
|
||||
contexts?: {
|
||||
[type: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
* Options passed to validator during validation.
|
||||
* @see https://github.com/typestack/class-validator
|
||||
*
|
||||
* class-validator@0.10.1
|
||||
* class-validator@0.13.0
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface ValidatorOptions {
|
||||
/**
|
||||
* If set to true then class-validator will print extra warning messages to the console when something is not right.
|
||||
*/
|
||||
enableDebugMessages?: boolean;
|
||||
/**
|
||||
* If set to true then validator will skip validation of all properties that are undefined in the validating object.
|
||||
*/
|
||||
@@ -33,6 +37,15 @@ export interface ValidatorOptions {
|
||||
* Groups to be used during validation of the object.
|
||||
*/
|
||||
groups?: string[];
|
||||
/**
|
||||
* Set default for `always` option of decorators. Default can be overridden in decorator options.
|
||||
*/
|
||||
always?: boolean;
|
||||
/**
|
||||
* If [groups]{@link ValidatorOptions#groups} is not given or is empty,
|
||||
* ignore decorators with at least one group.
|
||||
*/
|
||||
strictGroups?: boolean;
|
||||
/**
|
||||
* If set to true, the validation will not use default messages.
|
||||
* Error message always will be undefined if its not explicitly set.
|
||||
@@ -55,4 +68,8 @@ export interface ValidatorOptions {
|
||||
* Settings true will cause fail validation of unknown objects.
|
||||
*/
|
||||
forbidUnknownValues?: boolean;
|
||||
/**
|
||||
* When set to true, validation of the given property will stop after encountering the first error. Defaults to false.
|
||||
*/
|
||||
stopAtFirstError?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { RequestMethod } from '../../enums';
|
||||
import { CorsOptions } from '../../interfaces/external/cors-options.interface';
|
||||
import {
|
||||
CorsOptions,
|
||||
CorsOptionsDelegate,
|
||||
} from '../../interfaces/external/cors-options.interface';
|
||||
import { NestApplicationOptions } from '../../interfaces/nest-application-options.interface';
|
||||
|
||||
export type ErrorHandler<TRequest = any, TResponse = any> = (
|
||||
@@ -62,7 +65,7 @@ export interface HttpServer<TRequest = any, TResponse = any> {
|
||||
getRequestUrl?(request: TResponse): string;
|
||||
getInstance(): any;
|
||||
registerParserMiddleware(): any;
|
||||
enableCors(options: CorsOptions): any;
|
||||
enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>): any;
|
||||
getHttpServer(): any;
|
||||
initHttpServer(options: NestApplicationOptions): void;
|
||||
close(): any;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { CorsOptions } from './external/cors-options.interface';
|
||||
import {
|
||||
CorsOptions,
|
||||
CorsOptionsDelegate,
|
||||
} from './external/cors-options.interface';
|
||||
import { HttpsOptions } from './external/https-options.interface';
|
||||
import { NestApplicationContextOptions } from './nest-application-context-options.interface';
|
||||
|
||||
@@ -9,7 +12,7 @@ export interface NestApplicationOptions extends NestApplicationContextOptions {
|
||||
/**
|
||||
* CORS options from [CORS package](https://github.com/expressjs/cors#configuration-options)
|
||||
*/
|
||||
cors?: boolean | CorsOptions;
|
||||
cors?: boolean | CorsOptions | CorsOptionsDelegate<any>;
|
||||
/**
|
||||
* Whether to use underlying platform body parser.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { CorsOptions } from './external/cors-options.interface';
|
||||
import {
|
||||
CorsOptions,
|
||||
CorsOptionsDelegate,
|
||||
} from './external/cors-options.interface';
|
||||
import { CanActivate } from './features/can-activate.interface';
|
||||
import { NestInterceptor } from './features/nest-interceptor.interface';
|
||||
import { HttpServer } from './http/http-server.interface';
|
||||
@@ -30,7 +33,7 @@ export interface INestApplication extends INestApplicationContext {
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
enableCors(options?: CorsOptions): void;
|
||||
enableCors(options?: CorsOptions | CorsOptionsDelegate<any>): void;
|
||||
|
||||
/**
|
||||
* Starts the application.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/common",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"homepage": "https://nestjs.com",
|
||||
@@ -19,7 +19,7 @@
|
||||
"dependencies": {
|
||||
"axios": "0.21.1",
|
||||
"iterare": "1.2.1",
|
||||
"tslib": "2.0.3",
|
||||
"tslib": "2.1.0",
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '../decorators/core/injectable.decorator';
|
||||
import { Optional } from '../decorators/core/optional.decorator';
|
||||
import { clc, yellow } from '../utils/cli-colors.util';
|
||||
import { isObject } from '../utils/shared.utils';
|
||||
import { isObject, isPlainObject } from '../utils/shared.utils';
|
||||
|
||||
declare const process: any;
|
||||
|
||||
@@ -146,7 +146,7 @@ export class Logger implements LoggerService {
|
||||
isTimeDiffEnabled?: boolean,
|
||||
writeStreamType?: 'stdout' | 'stderr',
|
||||
) {
|
||||
const output = isObject(message)
|
||||
const output = isPlainObject(message)
|
||||
? `${color('Object:')}\n${JSON.stringify(message, null, 2)}\n`
|
||||
: color(message);
|
||||
|
||||
@@ -154,7 +154,10 @@ export class Logger implements LoggerService {
|
||||
const contextMessage = context ? yellow(`[${context}] `) : '';
|
||||
const timestampDiff = this.updateAndGetTimestampDiff(isTimeDiffEnabled);
|
||||
const instance = (this.instance as typeof Logger) ?? Logger;
|
||||
const computedMessage = `${pidMessage}${instance.getTimestamp()} ${contextMessage}${output}${timestampDiff}\n`;
|
||||
const timestamp = instance.getTimestamp
|
||||
? instance.getTimestamp()
|
||||
: Logger.getTimestamp?.();
|
||||
const computedMessage = `${pidMessage}${timestamp} ${contextMessage}${output}${timestampDiff}\n`;
|
||||
|
||||
process[writeStreamType ?? 'stdout'].write(computedMessage);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Controller } from '../../decorators/core/controller.decorator';
|
||||
describe('@Controller', () => {
|
||||
const reflectedPath = 'test';
|
||||
const reflectedHost = 'api.example.com';
|
||||
const reflectedHostArray = ['api1.example.com', 'api2.example.com'];
|
||||
|
||||
@Controller(reflectedPath)
|
||||
class Test {}
|
||||
@@ -14,6 +15,9 @@ describe('@Controller', () => {
|
||||
@Controller({ path: reflectedPath, host: reflectedHost })
|
||||
class PathAndHostDecorator {}
|
||||
|
||||
@Controller({ path: reflectedPath, host: reflectedHostArray })
|
||||
class PathAndHostArrayDecorator {}
|
||||
|
||||
@Controller({ host: reflectedHost })
|
||||
class HostOnlyDecorator {}
|
||||
|
||||
@@ -29,6 +33,8 @@ describe('@Controller', () => {
|
||||
expect(host).to.be.eql(reflectedHost);
|
||||
const host2 = Reflect.getMetadata('host', HostOnlyDecorator);
|
||||
expect(host2).to.be.eql(reflectedHost);
|
||||
const host3 = Reflect.getMetadata('host', PathAndHostArrayDecorator);
|
||||
expect(host3).to.be.eql(reflectedHostArray);
|
||||
});
|
||||
|
||||
it('should set default path when no object passed as param', () => {
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { HttpServer, RequestMethod } from '@nestjs/common';
|
||||
import { RequestHandler } from '@nestjs/common/interfaces';
|
||||
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import {
|
||||
CorsOptions,
|
||||
CorsOptionsDelegate,
|
||||
} from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
||||
|
||||
/**
|
||||
@@ -14,6 +17,14 @@ export abstract class AbstractHttpAdapter<
|
||||
protected httpServer: TServer;
|
||||
|
||||
constructor(protected readonly instance: any) {}
|
||||
all(path: string, handler: RequestHandler<TRequest, TResponse>);
|
||||
all(handler: RequestHandler<TRequest, TResponse>);
|
||||
all(path: any, handler?: any) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
setBaseViewsDir?(path: string | string[]): this {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
public async init() {}
|
||||
@@ -97,7 +108,10 @@ export abstract class AbstractHttpAdapter<
|
||||
abstract setNotFoundHandler(handler: Function, prefix?: string);
|
||||
abstract setHeader(response, name: string, value: string);
|
||||
abstract registerParserMiddleware(prefix?: string);
|
||||
abstract enableCors(options: CorsOptions, prefix?: string);
|
||||
abstract enableCors(
|
||||
options: CorsOptions | CorsOptionsDelegate<TRequest>,
|
||||
prefix?: string,
|
||||
);
|
||||
abstract createMiddlewareFactory(
|
||||
requestMethod: RequestMethod,
|
||||
):
|
||||
|
||||
@@ -14,12 +14,8 @@ export class ApplicationConfig {
|
||||
private globalInterceptors: NestInterceptor[] = [];
|
||||
private globalGuards: CanActivate[] = [];
|
||||
private readonly globalRequestPipes: InstanceWrapper<PipeTransform>[] = [];
|
||||
private readonly globalRequestFilters: InstanceWrapper<
|
||||
ExceptionFilter
|
||||
>[] = [];
|
||||
private readonly globalRequestInterceptors: InstanceWrapper<
|
||||
NestInterceptor
|
||||
>[] = [];
|
||||
private readonly globalRequestFilters: InstanceWrapper<ExceptionFilter>[] = [];
|
||||
private readonly globalRequestInterceptors: InstanceWrapper<NestInterceptor>[] = [];
|
||||
private readonly globalRequestGuards: InstanceWrapper<CanActivate>[] = [];
|
||||
|
||||
constructor(private ioAdapter: WebSocketAdapter | null = null) {}
|
||||
|
||||
@@ -38,9 +38,7 @@ export interface ExternalContextOptions {
|
||||
export class ExternalContextCreator {
|
||||
private readonly contextUtils = new ContextUtils();
|
||||
private readonly externalErrorProxy = new ExternalErrorProxy();
|
||||
private readonly handlerMetadataStorage = new HandlerMetadataStorage<
|
||||
ExternalHandlerMetadata
|
||||
>();
|
||||
private readonly handlerMetadataStorage = new HandlerMetadataStorage<ExternalHandlerMetadata>();
|
||||
private container: NestContainer;
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -9,7 +9,10 @@ import {
|
||||
PipeTransform,
|
||||
WebSocketAdapter,
|
||||
} from '@nestjs/common';
|
||||
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import {
|
||||
CorsOptions,
|
||||
CorsOptionsDelegate,
|
||||
} from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
||||
import { Logger } from '@nestjs/common/services/logger.service';
|
||||
import { loadPackage } from '@nestjs/common/utils/load-package.util';
|
||||
@@ -102,11 +105,15 @@ export class NestApplication
|
||||
if (!this.appOptions || !this.appOptions.cors) {
|
||||
return undefined;
|
||||
}
|
||||
const isCorsOptionsObj = isObject(this.appOptions.cors);
|
||||
if (!isCorsOptionsObj) {
|
||||
const passCustomOptions =
|
||||
isObject(this.appOptions.cors) ||
|
||||
typeof this.appOptions.cors === 'function';
|
||||
if (!passCustomOptions) {
|
||||
return this.enableCors();
|
||||
}
|
||||
return this.enableCors(this.appOptions.cors as CorsOptions);
|
||||
return this.enableCors(
|
||||
this.appOptions.cors as CorsOptions | CorsOptionsDelegate<any>,
|
||||
);
|
||||
}
|
||||
|
||||
public createServer<T = any>(): T {
|
||||
@@ -224,7 +231,7 @@ export class NestApplication
|
||||
return this;
|
||||
}
|
||||
|
||||
public enableCors(options?: CorsOptions): void {
|
||||
public enableCors(options?: CorsOptions | CorsOptionsDelegate<any>): void {
|
||||
this.httpAdapter.enableCors(options);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/core",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -32,11 +32,11 @@
|
||||
"iterare": "1.2.1",
|
||||
"object-hash": "2.1.1",
|
||||
"path-to-regexp": "3.2.0",
|
||||
"tslib": "2.0.3",
|
||||
"tslib": "2.1.0",
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "7.6.5"
|
||||
"@nestjs/common": "7.6.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
@@ -73,7 +73,7 @@ export class RouterExplorer {
|
||||
module: string,
|
||||
applicationRef: T,
|
||||
basePath: string,
|
||||
host: string,
|
||||
host: string | string[],
|
||||
) {
|
||||
const { instance } = instanceWrapper;
|
||||
const routerPaths = this.scanForPaths(instance);
|
||||
@@ -150,7 +150,7 @@ export class RouterExplorer {
|
||||
instanceWrapper: InstanceWrapper,
|
||||
moduleKey: string,
|
||||
basePath: string,
|
||||
host: string,
|
||||
host: string | string[],
|
||||
) {
|
||||
(routePaths || []).forEach(pathProperties => {
|
||||
const { path, requestMethod } = pathProperties;
|
||||
@@ -179,7 +179,7 @@ export class RouterExplorer {
|
||||
instanceWrapper: InstanceWrapper,
|
||||
moduleKey: string,
|
||||
basePath: string,
|
||||
host: string,
|
||||
host: string | string[],
|
||||
) {
|
||||
const {
|
||||
path: paths,
|
||||
@@ -216,14 +216,24 @@ export class RouterExplorer {
|
||||
});
|
||||
}
|
||||
|
||||
private applyHostFilter(host: string, handler: Function) {
|
||||
private applyHostFilter(host: string | string[], handler: Function) {
|
||||
if (!host) {
|
||||
return handler;
|
||||
}
|
||||
|
||||
const httpAdapterRef = this.container.getHttpAdapterRef();
|
||||
const keys = [];
|
||||
const re = pathToRegexp(host, keys);
|
||||
const hosts = Array.isArray(host) ? host : [host];
|
||||
const hostRegExps = hosts.map((host: string) => {
|
||||
const keys = [];
|
||||
const regexp = pathToRegexp(host, keys);
|
||||
return { regexp, keys };
|
||||
});
|
||||
|
||||
const unsupportedFilteringErrorMessage = Array.isArray(host)
|
||||
? `HTTP adapter does not support filtering on hosts: ["${host.join(
|
||||
'", "',
|
||||
)}"]`
|
||||
: `HTTP adapter does not support filtering on host: "${host}"`;
|
||||
|
||||
return <TRequest extends Record<string, any> = any, TResponse = any>(
|
||||
req: TRequest,
|
||||
@@ -232,14 +242,17 @@ export class RouterExplorer {
|
||||
) => {
|
||||
(req as Record<string, any>).hosts = {};
|
||||
const hostname = httpAdapterRef.getRequestHostname(req) || '';
|
||||
const match = hostname.match(re);
|
||||
if (match) {
|
||||
keys.forEach((key, i) => (req.hosts[key.name] = match[i + 1]));
|
||||
return handler(req, res, next);
|
||||
|
||||
for (const exp of hostRegExps) {
|
||||
const match = hostname.match(exp.regexp);
|
||||
if (match) {
|
||||
exp.keys.forEach((key, i) => (req.hosts[key.name] = match[i + 1]));
|
||||
return handler(req, res, next);
|
||||
}
|
||||
}
|
||||
if (!next) {
|
||||
throw new InternalServerErrorException(
|
||||
`HTTP adapter does not support filtering on host: "${host}"`,
|
||||
unsupportedFilteringErrorMessage,
|
||||
);
|
||||
}
|
||||
return next();
|
||||
|
||||
@@ -132,7 +132,7 @@ export class RoutesResolver implements Resolver {
|
||||
|
||||
private getHostMetadata(
|
||||
metatype: Type<unknown> | Function,
|
||||
): string | undefined {
|
||||
): string | string[] | undefined {
|
||||
return Reflect.getMetadata(HOST_METADATA, metatype);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Transport } from '../enums/transport.enum';
|
||||
import {
|
||||
ClientOptions,
|
||||
CustomClientOptions,
|
||||
TcpClientOptions,
|
||||
} from '../interfaces/client-metadata.interface';
|
||||
import { Closeable } from '../interfaces/closeable.interface';
|
||||
@@ -30,7 +31,16 @@ export class ClientProxyFactory {
|
||||
clientOptions: { transport: Transport.GRPC } & ClientOptions,
|
||||
): ClientGrpcProxy;
|
||||
public static create(clientOptions: ClientOptions): ClientProxy & Closeable;
|
||||
public static create(clientOptions: ClientOptions): ClientProxy & Closeable {
|
||||
public static create(
|
||||
clientOptions: CustomClientOptions,
|
||||
): ClientProxy & Closeable;
|
||||
public static create(
|
||||
clientOptions: ClientOptions | CustomClientOptions,
|
||||
): ClientProxy & Closeable {
|
||||
if (this.isCustomClientOptions(clientOptions)) {
|
||||
const { customClass, options } = clientOptions;
|
||||
return new customClass(options);
|
||||
}
|
||||
const { transport, options } = clientOptions;
|
||||
switch (transport) {
|
||||
case Transport.REDIS:
|
||||
@@ -49,4 +59,10 @@ export class ClientProxyFactory {
|
||||
return new ClientTCP(options as TcpClientOptions['options']);
|
||||
}
|
||||
}
|
||||
|
||||
private static isCustomClientOptions(
|
||||
options: ClientOptions | CustomClientOptions,
|
||||
): options is CustomClientOptions {
|
||||
return !!(options as CustomClientOptions).customClass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,17 +84,25 @@ export abstract class ClientProxy {
|
||||
): (packet: WritePacket) => void {
|
||||
return ({ err, response, isDisposed }: WritePacket) => {
|
||||
if (err) {
|
||||
return observer.error(err);
|
||||
return observer.error(this.serializeError(err));
|
||||
} else if (response !== undefined && isDisposed) {
|
||||
observer.next(response);
|
||||
observer.next(this.serializeResponse(response));
|
||||
return observer.complete();
|
||||
} else if (isDisposed) {
|
||||
return observer.complete();
|
||||
}
|
||||
observer.next(response);
|
||||
observer.next(this.serializeResponse(response));
|
||||
};
|
||||
}
|
||||
|
||||
protected serializeError(err: any): any {
|
||||
return err;
|
||||
}
|
||||
|
||||
protected serializeResponse(response: any): any {
|
||||
return response;
|
||||
}
|
||||
|
||||
protected assignPacketId(packet: ReadPacket): ReadPacket & PacketId {
|
||||
const id = randomStringGenerator();
|
||||
return Object.assign(packet, { id });
|
||||
|
||||
@@ -41,9 +41,7 @@ export interface RpcHandlerMetadata {
|
||||
export class RpcContextCreator {
|
||||
private readonly contextUtils = new ContextUtils();
|
||||
private readonly rpcParamsFactory = new RpcParamsFactory();
|
||||
private readonly handlerMetadataStorage = new HandlerMetadataStorage<
|
||||
RpcHandlerMetadata
|
||||
>();
|
||||
private readonly handlerMetadataStorage = new HandlerMetadataStorage<RpcHandlerMetadata>();
|
||||
|
||||
constructor(
|
||||
private readonly rpcProxy: RpcProxy,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Type } from '@nestjs/common';
|
||||
import { ClientProxy } from '../client';
|
||||
import { Transport } from '../enums/transport.enum';
|
||||
import { Deserializer } from './deserializer.interface';
|
||||
import {
|
||||
@@ -19,6 +21,11 @@ export type ClientOptions =
|
||||
| TcpClientOptions
|
||||
| RmqOptions;
|
||||
|
||||
export interface CustomClientOptions {
|
||||
customClass: Type<ClientProxy>;
|
||||
options?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface TcpClientOptions {
|
||||
transport: Transport.TCP;
|
||||
options?: {
|
||||
|
||||
@@ -27,7 +27,7 @@ export type MicroserviceOptions =
|
||||
| CustomStrategy;
|
||||
|
||||
export interface CustomStrategy {
|
||||
strategy: Server & CustomTransportStrategy;
|
||||
strategy: CustomTransportStrategy;
|
||||
options?: {};
|
||||
}
|
||||
|
||||
@@ -103,13 +103,19 @@ export interface MqttOptions {
|
||||
export interface NatsOptions {
|
||||
transport?: Transport.NATS;
|
||||
options?: {
|
||||
encoding?: string;
|
||||
url?: string;
|
||||
name?: string;
|
||||
user?: string;
|
||||
pass?: string;
|
||||
maxPingOut?: number;
|
||||
maxReconnectAttempts?: number;
|
||||
reconnectTimeWait?: number;
|
||||
reconnectJitter?: number;
|
||||
reconnectJitterTLS?: number;
|
||||
reconnectDelayHandler?: any;
|
||||
servers?: string[];
|
||||
nkey?: any;
|
||||
reconnect?: boolean;
|
||||
pedantic?: boolean;
|
||||
tls?: any;
|
||||
@@ -119,6 +125,18 @@ export interface NatsOptions {
|
||||
userJWT?: string;
|
||||
nonceSigner?: any;
|
||||
userCreds?: any;
|
||||
useOldRequestStyle?: boolean;
|
||||
pingInterval?: number;
|
||||
preserveBuffers?: boolean;
|
||||
waitOnFirstConnect?: boolean;
|
||||
verbose?: boolean;
|
||||
noEcho?: boolean;
|
||||
noRandomize?: boolean;
|
||||
timeout?: number;
|
||||
token?: string;
|
||||
yieldTime?: number;
|
||||
tokenHandler?: any;
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
import { ClientOptions } from '../../interfaces';
|
||||
import { ClientOptions, CustomClientOptions } from '../../interfaces';
|
||||
import { Type, Provider, ModuleMetadata } from '@nestjs/common/interfaces';
|
||||
|
||||
export type ClientProviderOptions = ClientOptions & {
|
||||
export type ClientProvider = ClientOptions | CustomClientOptions;
|
||||
|
||||
export type ClientProviderOptions = ClientProvider & {
|
||||
name: string | symbol;
|
||||
};
|
||||
|
||||
export type ClientsModuleOptions = Array<ClientProviderOptions>;
|
||||
|
||||
export interface ClientsModuleOptionsFactory {
|
||||
createClientOptions(): Promise<ClientOptions> | ClientOptions;
|
||||
createClientOptions(): Promise<ClientProvider> | ClientProvider;
|
||||
}
|
||||
|
||||
export interface ClientsProviderAsyncOptions
|
||||
extends Pick<ModuleMetadata, 'imports'> {
|
||||
useExisting?: Type<ClientsModuleOptionsFactory>;
|
||||
useClass?: Type<ClientsModuleOptionsFactory>;
|
||||
useFactory?: (...args: any[]) => Promise<ClientOptions> | ClientOptions;
|
||||
useFactory?: (...args: any[]) => Promise<ClientProvider> | ClientProvider;
|
||||
inject?: any[];
|
||||
extraProviders?: Provider[];
|
||||
name: string | symbol;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/microservices",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -19,11 +19,11 @@
|
||||
"dependencies": {
|
||||
"iterare": "1.2.1",
|
||||
"json-socket": "0.3.0",
|
||||
"tslib": "2.0.3"
|
||||
"tslib": "2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "7.6.5",
|
||||
"@nestjs/core": "7.6.5"
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { RequestMethod } from '@nestjs/common';
|
||||
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import {
|
||||
CorsOptions,
|
||||
CorsOptionsDelegate,
|
||||
} from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
||||
import { isFunction, isNil, isObject } from '@nestjs/common/utils/shared.utils';
|
||||
import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter';
|
||||
@@ -108,7 +111,7 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
||||
return request.originalUrl;
|
||||
}
|
||||
|
||||
public enableCors(options: CorsOptions) {
|
||||
public enableCors(options: CorsOptions | CorsOptionsDelegate<any>) {
|
||||
return this.use(cors(options));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-express",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -21,11 +21,11 @@
|
||||
"cors": "2.8.5",
|
||||
"express": "4.17.1",
|
||||
"multer": "1.4.2",
|
||||
"tslib": "2.0.3"
|
||||
"tslib": "2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "7.6.5",
|
||||
"@nestjs/core": "7.6.5"
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
import { HttpStatus, Logger, RequestMethod } from '@nestjs/common';
|
||||
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import {
|
||||
CorsOptions,
|
||||
CorsOptionsDelegate,
|
||||
} from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
import { loadPackage } from '@nestjs/common/utils/load-package.util';
|
||||
import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter';
|
||||
import {
|
||||
@@ -257,8 +260,18 @@ export class FastifyAdapter<
|
||||
return request.raw ? request.raw.url : request.url;
|
||||
}
|
||||
|
||||
public enableCors(options: CorsOptions) {
|
||||
this.register(require('fastify-cors'), options);
|
||||
public enableCors(
|
||||
options:
|
||||
| CorsOptions
|
||||
| CorsOptionsDelegate<
|
||||
FastifyRequest<RequestGenericInterface, TServer, TRawRequest>
|
||||
>,
|
||||
) {
|
||||
if (typeof options === 'function') {
|
||||
this.register(require('fastify-cors'), () => options);
|
||||
} else {
|
||||
this.register(require('fastify-cors'), options);
|
||||
}
|
||||
}
|
||||
|
||||
public registerParserMiddleware() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-fastify",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -17,13 +17,13 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"fastify": "3.9.2",
|
||||
"fastify-cors": "5.1.0",
|
||||
"fastify": "3.11.0",
|
||||
"fastify-cors": "5.2.0",
|
||||
"fastify-formbody": "5.0.0",
|
||||
"light-my-request": "4.4.1",
|
||||
"middie": "5.2.0",
|
||||
"path-to-regexp": "3.2.0",
|
||||
"tslib": "2.0.3"
|
||||
"tslib": "2.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-socket.io",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-socket.io)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -17,8 +17,8 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"socket.io": "2.3.0",
|
||||
"tslib": "2.0.3"
|
||||
"socket.io": "2.4.1",
|
||||
"tslib": "2.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/platform-ws",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-ws)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -17,8 +17,8 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": "2.0.3",
|
||||
"ws": "7.4.1"
|
||||
"tslib": "2.1.0",
|
||||
"ws": "7.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/testing",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@testing)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"optional": "0.1.4",
|
||||
"tslib": "2.0.3"
|
||||
"tslib": "2.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Logger, Module } from '@nestjs/common';
|
||||
import { Logger, LoggerService, Module } from '@nestjs/common';
|
||||
import { ModuleMetadata } from '@nestjs/common/interfaces';
|
||||
import { ApplicationConfig } from '@nestjs/core/application-config';
|
||||
import { NestContainer } from '@nestjs/core/injector/container';
|
||||
@@ -16,6 +16,7 @@ export class TestingModuleBuilder {
|
||||
private readonly scanner: DependenciesScanner;
|
||||
private readonly instanceLoader = new InstanceLoader(this.container);
|
||||
private readonly module: any;
|
||||
private testingLogger: LoggerService;
|
||||
|
||||
constructor(metadataScanner: MetadataScanner, metadata: ModuleMetadata) {
|
||||
this.scanner = new DependenciesScanner(
|
||||
@@ -26,6 +27,11 @@ export class TestingModuleBuilder {
|
||||
this.module = this.createModule(metadata);
|
||||
}
|
||||
|
||||
public setLogger(testingLogger: LoggerService) {
|
||||
this.testingLogger = testingLogger;
|
||||
return this;
|
||||
}
|
||||
|
||||
public overridePipe<T = any>(typeOrToken: T): OverrideBy {
|
||||
return this.override(typeOrToken, false);
|
||||
}
|
||||
@@ -98,6 +104,6 @@ export class TestingModuleBuilder {
|
||||
}
|
||||
|
||||
private applyLogger() {
|
||||
Logger.overrideLogger(new TestingLogger());
|
||||
Logger.overrideLogger(this.testingLogger || new TestingLogger());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Principal Sponsors
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="180" valign="middle" /></a></td>
|
||||
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
||||
<td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
#### Gold Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
||||
|
||||
#### Silver Sponsors
|
||||
|
||||
<table style="text-align:center;"><tr><td>
|
||||
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
||||
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
||||
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
||||
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
||||
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
||||
|
||||
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
<td align="center" valign="middle">
|
||||
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
||||
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
||||
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
||||
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
||||
</tr></table>
|
||||
|
||||
## Backers
|
||||
|
||||
@@ -39,9 +39,7 @@ export interface WsHandlerMetadata {
|
||||
export class WsContextCreator {
|
||||
private readonly contextUtils = new ContextUtils();
|
||||
private readonly wsParamsFactory = new WsParamsFactory();
|
||||
private readonly handlerMetadataStorage = new HandlerMetadataStorage<
|
||||
WsHandlerMetadata
|
||||
>();
|
||||
private readonly handlerMetadataStorage = new HandlerMetadataStorage<WsHandlerMetadata>();
|
||||
|
||||
constructor(
|
||||
private readonly wsProxy: WsProxy,
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface GatewayMetadata {
|
||||
* Accepted origins
|
||||
* @default '*:*'
|
||||
*/
|
||||
origins?: string;
|
||||
origins?: string | string[];
|
||||
|
||||
parser?: any;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nestjs/websockets",
|
||||
"version": "7.6.5",
|
||||
"version": "7.6.8",
|
||||
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)",
|
||||
"author": "Kamil Mysliwiec",
|
||||
"license": "MIT",
|
||||
@@ -13,11 +13,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"iterare": "1.2.1",
|
||||
"tslib": "2.0.3"
|
||||
"tslib": "2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "7.6.5",
|
||||
"@nestjs/core": "7.6.5"
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.0",
|
||||
|
||||
70
readme_jp.md
Normal file
70
readme_jp.md
Normal file
@@ -0,0 +1,70 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">すばやくスケーラブルなサーバーサイドアプリケーションを構築するための革新的な<a href="http://nodejs.org" target="_blank">Node.js</a>フレームワークです。</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
すばやくスケーラブルなサーバーサイドアプリケーションを構築するための革新的な<a href="http://nodejs.org" target="_blank">Node.js</a>フレームワークです。最新のJavaScriptを使用し、<a href="http://www.typescriptlang.org" target="_blank">TypeScript</a>(JavaScriptを拡張したスーパーセット)で構築され 、OOP(オブジェクト指向プログラミング)、FP(関数型プログラミング)、およびFRP(関数型リアクティブプログラミング)の要素を取り入れています。
|
||||
|
||||
<p>Nestは<a href="https://expressjs.com/" target="_blank">Express</a>(デフォルト)や<a href="https://github.com/fastify/fastify" target="_blank">Fastify</a>などのさまざまなライブラリとの互換性を提供することで、たくさんのサードパーティプラグインを簡単に使用することができます。
|
||||
</p>
|
||||
|
||||
## Philosophy
|
||||
|
||||
<p>
|
||||
近年、Node.jsの発展によって、JavaScriptはフロントエンドとバックエンドの両方でWebの「共通言語」になりました。そしてフロントエンドでは、<a href="https://angular.io/" target="_blank">Angular</a>、<a href="https://github.com/facebook/react" target="_blank">React</a>、<a href="https://github.com/vuejs/vue" target="_blank">Vue</a>などの素晴らしいプロジェクトが生まれ、開発効率が飛躍的に向上しました。一方で、サーバーサイドでは、Node.jsエコシステム上に優れたライブラリ、ヘルパー、ツールがたくさんありますが、それらのどれもが主要な問題であるアーキテクチャを効果的に解決するものではありませんでした。
|
||||
</p>
|
||||
|
||||
<p>Nestは、実用的なアーキテクチャをすぐに構築できることを目的としています。具体的には、テストフレンドリーで、スケーラブルで、疎結合で、運用にやさしいアプリケーションを構築できるようになっています。また、アーキテクチャはAngularにインスパイアされています。</p>
|
||||
|
||||
## Getting started
|
||||
|
||||
* To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
|
||||
* 要查看中文 [指南](readme_zh.md), 请访问 [docs.nestjs.cn](https://docs.nestjs.cn). :books:
|
||||
* 日本語ガイドは現在準備中です。 :books:
|
||||
|
||||
## Questions
|
||||
|
||||
質問やサポートについては、公式の[Discordチャンネル](https://discord.gg/G7Qnnhy)を使用してください。また、このリポジトリのissueリストは、バグレポートと機能リクエスト **専用** です。
|
||||
|
||||
## Issues
|
||||
|
||||
issueを開く前に、必ず[Issue Reporting Checklist](https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md#-submitting-an-issue)をお読みください。ガイドラインに準拠していないissueは、クローズされる場合があります。
|
||||
|
||||
## Consulting
|
||||
|
||||
公式サポートを利用することで、Nestコアチームからのテクニカルサポート、移行戦略、ベストプラクティスの提供、アーキテクチャの相談、PRレビュー、メンタリングを受けることができます。詳しくは[こちら](https://enterprise.nestjs.com)をご覧ください。
|
||||
|
||||
## Support
|
||||
|
||||
Nestは、MITライセンスのオープンソースプロジェクトです。スポンサーと支援者による素晴らしいサポートによって、その発展を支えられています。参加したい場合は[こちら](https://docs.nestjs.com/support)をご覧ください。
|
||||
|
||||
## Stay in touch
|
||||
|
||||
* Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
||||
* Website - [https://nestjs.com](https://nestjs.com/)
|
||||
* Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
||||
1299
sample/01-cats-app/package-lock.json
generated
1299
sample/01-cats-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,34 +19,34 @@
|
||||
"test:e2e": "jest --config ./e2e/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/jest": "26.0.19",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/jest": "26.0.20",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
},
|
||||
|
||||
1626
sample/02-gateways/package-lock.json
generated
1626
sample/02-gateways/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,39 +19,39 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"@nestjs/platform-socket.io": "7.6.4",
|
||||
"@nestjs/websockets": "7.6.4",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"@nestjs/platform-socket.io": "7.6.8",
|
||||
"@nestjs/websockets": "7.6.8",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3",
|
||||
"socket.io-redis": "5.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/socket.io": "2.1.12",
|
||||
"@types/socket.io": "2.1.13",
|
||||
"@types/socket.io-redis": "1.0.26",
|
||||
"@types/ws": "7.4.0",
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
1170
sample/03-microservices/package-lock.json
generated
1170
sample/03-microservices/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,35 +19,35 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/microservices": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/microservices": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/amqplib": "0.5.17",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
1146
sample/04-grpc/package-lock.json
generated
1146
sample/04-grpc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,12 +19,12 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@grpc/proto-loader": "0.5.5",
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/microservices": "7.6.4",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"@grpc/proto-loader": "0.5.6",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/microservices": "7.6.8",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"grpc": "1.24.4",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
@@ -32,23 +32,23 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"@types/ws": "7.4.0",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
1134
sample/05-sql-typeorm/package-lock.json
generated
1134
sample/05-sql-typeorm/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,35 +19,35 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"@nestjs/typeorm": "7.1.5",
|
||||
"mysql": "2.18.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3",
|
||||
"typeorm": "0.2.29"
|
||||
"typeorm": "0.2.30"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"@types/ws": "7.4.0",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
1093
sample/06-mongoose/package-lock.json
generated
1093
sample/06-mongoose/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,11 +19,11 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/mongoose": "7.2.0",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"mongoose": "5.11.8",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/mongoose": "7.2.2",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"mongoose": "5.11.14",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3"
|
||||
@@ -31,23 +31,23 @@
|
||||
"devDependencies": {
|
||||
"@types/mongoose": "5.10.3",
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"@types/ws": "7.4.0",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
1136
sample/07-sequelize/package-lock.json
generated
1136
sample/07-sequelize/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,38 +19,38 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"@nestjs/sequelize": "0.1.1",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"@nestjs/sequelize": "0.2.0",
|
||||
"mysql2": "2.2.5",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3",
|
||||
"sequelize": "6.3.5",
|
||||
"sequelize-typescript": "1.1.0",
|
||||
"sequelize": "6.5.0",
|
||||
"sequelize-typescript": "2.0.0",
|
||||
"typescript": "4.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/sequelize": "4.28.9",
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"@types/ws": "7.4.0",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectModel } from '@nestjs/sequelize';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { CreateUserDto } from './dto/create-user.dto';
|
||||
import { User } from './user.model';
|
||||
|
||||
@@ -9,7 +8,6 @@ export class UsersService {
|
||||
constructor(
|
||||
@InjectModel(User)
|
||||
private readonly userModel: typeof User,
|
||||
private readonly sequelize: Sequelize,
|
||||
) {}
|
||||
|
||||
create(createUserDto: CreateUserDto): Promise<User> {
|
||||
@@ -21,23 +19,6 @@ export class UsersService {
|
||||
}
|
||||
|
||||
async findAll(): Promise<User[]> {
|
||||
try {
|
||||
await this.sequelize.transaction(async t => {
|
||||
const transactionHost = { transaction: t };
|
||||
|
||||
await this.userModel.create(
|
||||
{ firstName: 'Abraham', lastName: 'Lincoln' },
|
||||
transactionHost,
|
||||
);
|
||||
await this.userModel.create(
|
||||
{ firstName: 'John', lastName: 'Boothe' },
|
||||
transactionHost,
|
||||
);
|
||||
});
|
||||
} catch (err) {
|
||||
// Transaction has been rolled back
|
||||
// err is whatever rejected the promise chain returned to the transaction callback
|
||||
}
|
||||
return this.userModel.findAll();
|
||||
}
|
||||
|
||||
|
||||
1952
sample/08-webpack/package-lock.json
generated
1952
sample/08-webpack/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,27 +11,27 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.6.3",
|
||||
"typescript": "4.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@types/node": "14.14.14",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@types/node": "14.14.22",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"start-server-webpack-plugin": "2.2.5",
|
||||
"ts-loader": "8.0.12",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"webpack": "5.11.1",
|
||||
"webpack-cli": "4.3.0",
|
||||
"webpack": "5.19.0",
|
||||
"webpack-cli": "4.4.0",
|
||||
"webpack-node-externals": "2.5.2"
|
||||
}
|
||||
}
|
||||
|
||||
13382
sample/09-babel-example/package-lock.json
generated
13382
sample/09-babel-example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -13,11 +13,11 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"@nestjs/microservices": "7.6.4",
|
||||
"@nestjs/websockets": "7.6.4",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"@nestjs/microservices": "7.6.8",
|
||||
"@nestjs/websockets": "7.6.8",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.6.3"
|
||||
},
|
||||
@@ -30,11 +30,11 @@
|
||||
"@babel/preset-env": "7.12.11",
|
||||
"@babel/register": "7.12.10",
|
||||
"@babel/runtime": "7.12.5",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"jest": "26.6.3",
|
||||
"nodemon": "2.0.6",
|
||||
"nodemon": "2.0.7",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1"
|
||||
"supertest": "6.1.3"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
|
||||
1197
sample/10-fastify/package-lock.json
generated
1197
sample/10-fastify/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,34 +19,34 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-fastify": "7.6.4",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-fastify": "7.6.8",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"@types/ws": "7.4.0",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
1174
sample/11-swagger/package-lock.json
generated
1174
sample/11-swagger/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,12 +19,12 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"@nestjs/swagger": "4.7.9",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"@nestjs/swagger": "4.7.12",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rimraf": "3.0.2",
|
||||
"rxjs": "6.6.3",
|
||||
@@ -32,22 +32,22 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
1909
sample/12-graphql-schema-first/package-lock.json
generated
1909
sample/12-graphql-schema-first/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -19,14 +19,14 @@
|
||||
"test:e2e": "echo 'No e2e tests implemented yet.'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.6.4",
|
||||
"@nestjs/core": "7.6.4",
|
||||
"@nestjs/graphql": "7.9.2",
|
||||
"@nestjs/platform-express": "7.6.4",
|
||||
"apollo-server": "2.19.1",
|
||||
"apollo-server-express": "2.19.1",
|
||||
"class-transformer": "0.3.1",
|
||||
"class-validator": "0.12.2",
|
||||
"@nestjs/common": "7.6.8",
|
||||
"@nestjs/core": "7.6.8",
|
||||
"@nestjs/graphql": "7.9.8",
|
||||
"@nestjs/platform-express": "7.6.8",
|
||||
"apollo-server": "2.19.2",
|
||||
"apollo-server-express": "2.19.2",
|
||||
"class-transformer": "0.3.2",
|
||||
"class-validator": "0.13.1",
|
||||
"graphql": "15.4.0",
|
||||
"graphql-subscriptions": "1.1.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
@@ -35,22 +35,22 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.4",
|
||||
"@nestjs/schematics": "7.2.6",
|
||||
"@nestjs/testing": "7.6.4",
|
||||
"@types/express": "4.17.9",
|
||||
"@types/node": "14.14.14",
|
||||
"@nestjs/schematics": "7.2.7",
|
||||
"@nestjs/testing": "7.6.8",
|
||||
"@types/express": "4.17.11",
|
||||
"@types/node": "14.14.22",
|
||||
"@types/supertest": "2.0.10",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"supertest": "6.0.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"ts-loader": "8.0.12",
|
||||
"supertest": "6.1.3",
|
||||
"ts-jest": "26.5.0",
|
||||
"ts-loader": "8.0.14",
|
||||
"ts-node": "9.1.1",
|
||||
"tsconfig-paths": "3.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.0",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.14.2",
|
||||
"@typescript-eslint/parser": "4.14.2",
|
||||
"eslint": "7.19.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"typescript": "4.1.3"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Parent, ResolveField, Resolver } from '@nestjs/graphql';
|
||||
import { Cat, Owner } from '../graphql.schema';
|
||||
import { OwnersService } from '../owners/owners.service';
|
||||
|
||||
@Resolver('Cat')
|
||||
export class CatOwnerResolver {
|
||||
constructor(private readonly ownersService: OwnersService) {}
|
||||
|
||||
@ResolveField()
|
||||
async owner(@Parent() cat: Cat & { ownerId: number }): Promise<Owner> {
|
||||
return this.ownersService.findOneById(cat.ownerId);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
type Query {
|
||||
getCats: [Cat]
|
||||
cats: [Cat]
|
||||
cat(id: ID!): Cat
|
||||
}
|
||||
|
||||
@@ -11,10 +11,18 @@ type Subscription {
|
||||
catCreated: Cat
|
||||
}
|
||||
|
||||
type Owner {
|
||||
id: Int!
|
||||
name: String!
|
||||
age: Int
|
||||
cats: [Cat!]
|
||||
}
|
||||
|
||||
type Cat {
|
||||
id: Int
|
||||
name: String
|
||||
age: Int
|
||||
owner: Owner
|
||||
}
|
||||
|
||||
input CreateCatInput {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CatsResolvers } from './cats.resolvers';
|
||||
import { OwnersModule } from '../owners/owners.module';
|
||||
import { CatOwnerResolver } from './cat-owner.resolver';
|
||||
import { CatsResolver } from './cats.resolver';
|
||||
import { CatsService } from './cats.service';
|
||||
|
||||
@Module({
|
||||
providers: [CatsService, CatsResolvers],
|
||||
imports: [OwnersModule],
|
||||
providers: [CatsService, CatsResolver, CatOwnerResolver],
|
||||
})
|
||||
export class CatsModule {}
|
||||
|
||||
@@ -9,10 +9,10 @@ import { CreateCatDto } from './dto/create-cat.dto';
|
||||
const pubSub = new PubSub();
|
||||
|
||||
@Resolver('Cat')
|
||||
export class CatsResolvers {
|
||||
export class CatsResolver {
|
||||
constructor(private readonly catsService: CatsService) {}
|
||||
|
||||
@Query()
|
||||
@Query('cats')
|
||||
@UseGuards(CatsGuard)
|
||||
async getCats() {
|
||||
return this.catsService.findAll();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user