mirror of
https://github.com/nestjs/nest.git
synced 2026-02-24 00:02:56 +00:00
Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de9664831c | ||
|
|
26eeeb598e | ||
|
|
49f97cf72c | ||
|
|
15a6d890a5 | ||
|
|
a3c1bdc061 | ||
|
|
b75460b34f | ||
|
|
25a3684dcf | ||
|
|
9e322c1ed1 | ||
|
|
767ccd3e92 | ||
|
|
0368d5267c | ||
|
|
005d16f447 | ||
|
|
d37ec239c4 | ||
|
|
558e33f25c | ||
|
|
5172ef3c49 | ||
|
|
cdccb8ed97 | ||
|
|
4d407ab239 | ||
|
|
58120783d5 | ||
|
|
9732e8a0f4 | ||
|
|
dabf8a24c7 | ||
|
|
447372a485 | ||
|
|
4b042af629 | ||
|
|
ff828b9e86 | ||
|
|
806f079c2c | ||
|
|
a2880d02bd | ||
|
|
ce498e8615 | ||
|
|
14f737f770 | ||
|
|
a9922dab23 | ||
|
|
b1f7096432 | ||
|
|
d5dca175d7 | ||
|
|
66c0b8cf5c | ||
|
|
e3356cf19e | ||
|
|
4b6ca2a3e0 | ||
|
|
137e8fd408 | ||
|
|
03f2832a2d | ||
|
|
d9a9e7df2f | ||
|
|
a3fe26babf | ||
|
|
71cc0dea61 | ||
|
|
6198204b0b | ||
|
|
32953148df | ||
|
|
603ed2de28 | ||
|
|
b272ec313b | ||
|
|
25588d83d0 | ||
|
|
d4c0969f1a | ||
|
|
2d942a8405 | ||
|
|
e0f5e1d5ca | ||
|
|
e8c815d8ec | ||
|
|
149176ae6f | ||
|
|
fa3ee7e2aa | ||
|
|
d5880506df | ||
|
|
dfd0d17126 | ||
|
|
9638c18020 | ||
|
|
9ef356b30f | ||
|
|
1a7ab4e5f9 | ||
|
|
c5da005d81 | ||
|
|
76beabe686 | ||
|
|
e766ea72ba | ||
|
|
2f535c33ae | ||
|
|
20dd9fc8ca | ||
|
|
6110526402 | ||
|
|
0a1f44ac4d | ||
|
|
d048f23ff8 | ||
|
|
f5f8255a37 | ||
|
|
cc4d91fcb3 | ||
|
|
b296cabd35 | ||
|
|
b8a66efbba | ||
|
|
89c76a682e | ||
|
|
63577b9986 | ||
|
|
713e97f6c3 | ||
|
|
c392da09a6 | ||
|
|
02d4841d05 | ||
|
|
cbe9ed4980 | ||
|
|
d654e5e84f | ||
|
|
9d2bd82173 | ||
|
|
02affa5677 | ||
|
|
71a023ebae | ||
|
|
aa75b52255 | ||
|
|
6cf7cdc2a6 | ||
|
|
5b804f5a35 | ||
|
|
b348920d25 | ||
|
|
b6fe9b06cc | ||
|
|
fde2041f17 | ||
|
|
7a4b0e64ad | ||
|
|
afe9c4b5f4 | ||
|
|
5e6694cb8b | ||
|
|
d20f6bb653 | ||
|
|
e8032f37fc | ||
|
|
cae159e77c | ||
|
|
47812f5822 | ||
|
|
afa9903882 | ||
|
|
a7d465bfa1 | ||
|
|
95dfd59e4e | ||
|
|
08e6278a77 | ||
|
|
fbf47a2825 | ||
|
|
643e84c49a | ||
|
|
25c7e8909e | ||
|
|
0d5972c66b | ||
|
|
394d7f23bf | ||
|
|
09d9c6597f | ||
|
|
1d8c8ee264 | ||
|
|
5a9d6d6d14 | ||
|
|
4d13ee8100 | ||
|
|
6b0ae0602c | ||
|
|
d0bd2f7b20 | ||
|
|
5f965cf174 | ||
|
|
504a10ce5e | ||
|
|
a9abd1c2ea | ||
|
|
e7e859adce | ||
|
|
0c98a65e79 | ||
|
|
ba2eeeeac7 |
@@ -186,7 +186,7 @@ Samples: (even more [samples](https://github.com/nestjs/nest/commits/master))
|
||||
docs(changelog) update change log to beta.5
|
||||
```
|
||||
```
|
||||
bugfix(@nestjs/core) need to depend on latest rxjs and zone.js
|
||||
bugfix(core) need to depend on latest rxjs and zone.js
|
||||
|
||||
The version in our package.json gets copied to the one we publish, and users need the latest of these.
|
||||
```
|
||||
|
||||
@@ -58,7 +58,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="34" /></a>
|
||||
|
||||
|
||||
## Backers
|
||||
|
||||
|
||||
48
benchmarks/all_output.txt
Normal file
48
benchmarks/all_output.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
-----------------------
|
||||
express
|
||||
-----------------------
|
||||
Running 10s test @ http://localhost:3000
|
||||
8 threads and 1024 connections
|
||||
Thread Stats Avg Stdev Max +/- Stdev
|
||||
Latency 47.78ms 19.09ms 212.47ms 66.94%
|
||||
Req/Sec 1.31k 268.90 2.07k 72.38%
|
||||
104687 requests in 10.02s, 21.47MB read
|
||||
Socket errors: connect 0, read 877, write 0, timeout 0
|
||||
Requests/sec: 10444.24
|
||||
Transfer/sec: 2.14MB
|
||||
-----------------------
|
||||
fastify
|
||||
-----------------------
|
||||
Running 10s test @ http://localhost:3000
|
||||
8 threads and 1024 connections
|
||||
Thread Stats Avg Stdev Max +/- Stdev
|
||||
Latency 21.80ms 8.73ms 78.12ms 55.78%
|
||||
Req/Sec 2.99k 0.92k 5.67k 68.88%
|
||||
238550 requests in 10.02s, 31.17MB read
|
||||
Socket errors: connect 0, read 862, write 0, timeout 0
|
||||
Requests/sec: 23795.79
|
||||
Transfer/sec: 3.11MB
|
||||
-----------------------
|
||||
nest
|
||||
-----------------------
|
||||
Running 10s test @ http://localhost:3000
|
||||
8 threads and 1024 connections
|
||||
Thread Stats Avg Stdev Max +/- Stdev
|
||||
Latency 54.00ms 22.33ms 200.25ms 62.23%
|
||||
Req/Sec 1.15k 338.60 1.88k 66.12%
|
||||
91348 requests in 10.05s, 18.82MB read
|
||||
Socket errors: connect 0, read 983, write 0, timeout 0
|
||||
Requests/sec: 9093.64
|
||||
Transfer/sec: 1.87MB
|
||||
-----------------------
|
||||
nest-fastify
|
||||
-----------------------
|
||||
Running 10s test @ http://localhost:3000
|
||||
8 threads and 1024 connections
|
||||
Thread Stats Avg Stdev Max +/- Stdev
|
||||
Latency 29.31ms 11.71ms 101.96ms 70.03%
|
||||
Req/Sec 2.17k 0.93k 4.12k 63.13%
|
||||
173241 requests in 10.05s, 22.80MB read
|
||||
Socket errors: connect 0, read 934, write 0, timeout 0
|
||||
Requests/sec: 17233.87
|
||||
Transfer/sec: 2.27MB
|
||||
7
benchmarks/express.js
Normal file
7
benchmarks/express.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
|
||||
app.get('/', async (req, res) => res.send('Hello world'));
|
||||
app.listen(3000);
|
||||
5
benchmarks/fastify.js
Normal file
5
benchmarks/fastify.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const fastify = require('fastify')();
|
||||
fastify.get('/', async (req, reply) => reply.send('Hello world'));
|
||||
fastify.listen(3000);
|
||||
9
benchmarks/nest-fastify.js
Normal file
9
benchmarks/nest-fastify.js
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
const core_1 = require('@nestjs/core');
|
||||
const app_module_1 = require('./nest/app.module');
|
||||
core_1.NestFactory.create(app_module_1.AppModule, new core_1.FastifyAdapter(), {
|
||||
logger: false,
|
||||
bodyParser: false,
|
||||
}).then(app => app.listen(3000));
|
||||
//# sourceMappingURL=main.js.map
|
||||
9
benchmarks/nest.js
Normal file
9
benchmarks/nest.js
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
const core_1 = require('@nestjs/core');
|
||||
const app_module_1 = require('./nest/app.module');
|
||||
core_1.NestFactory.create(app_module_1.AppModule, {
|
||||
logger: false,
|
||||
bodyParser: false,
|
||||
}).then(app => app.listen(3000));
|
||||
//# sourceMappingURL=main.js.map
|
||||
3
benchmarks/nest/app.controller.d.ts
vendored
Normal file
3
benchmarks/nest/app.controller.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare class AppController {
|
||||
root(): string;
|
||||
}
|
||||
28
benchmarks/nest/app.controller.js
Normal file
28
benchmarks/nest/app.controller.js
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AppController = class AppController {
|
||||
root() {
|
||||
return 'Hello world!';
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
common_1.Get(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", String)
|
||||
], AppController.prototype, "root", null);
|
||||
AppController = __decorate([
|
||||
common_1.Controller()
|
||||
], AppController);
|
||||
exports.AppController = AppController;
|
||||
//# sourceMappingURL=app.controller.js.map
|
||||
1
benchmarks/nest/app.controller.js.map
Normal file
1
benchmarks/nest/app.controller.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAiD;AAGjD,IAAa,aAAa,GAA1B,MAAa,aAAa;IAExB,IAAI;QACF,OAAO,cAAc,CAAA;IACvB,CAAC;CACF,CAAA;AAHC;IADC,YAAG,EAAE;;;;yCAGL;AAJU,aAAa;IADzB,mBAAU,EAAE;GACA,aAAa,CAKzB;AALY,sCAAa"}
|
||||
1
benchmarks/nest/app.module.d.ts
vendored
Normal file
1
benchmarks/nest/app.module.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare class AppModule {}
|
||||
20
benchmarks/nest/app.module.js
Normal file
20
benchmarks/nest/app.module.js
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common_1 = require("@nestjs/common");
|
||||
const app_controller_1 = require("./app.controller");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
AppModule = __decorate([
|
||||
common_1.Module({
|
||||
imports: [],
|
||||
controllers: [app_controller_1.AppController],
|
||||
})
|
||||
], AppModule);
|
||||
exports.AppModule = AppModule;
|
||||
//# sourceMappingURL=app.module.js.map
|
||||
1
benchmarks/nest/app.module.js.map
Normal file
1
benchmarks/nest/app.module.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AAMjD,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAJrB,eAAM,CAAC;QACN,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAC,8BAAa,CAAC;KAC7B,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
|
||||
1
benchmarks/nest/main.d.ts
vendored
Normal file
1
benchmarks/nest/main.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
1
benchmarks/nest/main.js.map
Normal file
1
benchmarks/nest/main.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"}
|
||||
14
benchmarks/run.sh
Normal file
14
benchmarks/run.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo 'Library:' $1
|
||||
node $1 &
|
||||
pid=$!
|
||||
|
||||
sleep 2
|
||||
|
||||
wrk 'http://localhost:3000' \
|
||||
-d 10 \
|
||||
-c 1024 \
|
||||
-t 8
|
||||
|
||||
kill $pid
|
||||
23
benchmarks/run_all.sh
Normal file
23
benchmarks/run_all.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
: > all_output.txt
|
||||
|
||||
lib=(express fastify nest nest-fastify)
|
||||
for item in ${lib[*]}
|
||||
do
|
||||
echo '-----------------------' >> all_output.txt
|
||||
echo $item >> all_output.txt
|
||||
echo '-----------------------' >> all_output.txt
|
||||
|
||||
node $item &
|
||||
pid=$!
|
||||
|
||||
sleep 2
|
||||
|
||||
wrk 'http://localhost:3000' \
|
||||
-d 10 \
|
||||
-c 1024 \
|
||||
-t 8 >> all_output.txt
|
||||
|
||||
kill $pid
|
||||
done
|
||||
@@ -58,7 +58,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
||||
|
||||
#### Sponsors
|
||||
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
|
||||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="34" /></a>
|
||||
|
||||
|
||||
## Backers
|
||||
|
||||
|
||||
3
bundle/common/cache/cache.constants.d.ts
vendored
Normal file
3
bundle/common/cache/cache.constants.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const CACHE_MANAGER = "CACHE_MANAGER";
|
||||
export declare const CACHE_MODULE_OPTIONS = "CACHE_MODULE_OPTIONS";
|
||||
export declare const CACHE_KEY_METADATA = "cache_module:cache_key";
|
||||
5
bundle/common/cache/cache.constants.js
vendored
Normal file
5
bundle/common/cache/cache.constants.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CACHE_MANAGER = 'CACHE_MANAGER';
|
||||
exports.CACHE_MODULE_OPTIONS = 'CACHE_MODULE_OPTIONS';
|
||||
exports.CACHE_KEY_METADATA = 'cache_module:cache_key';
|
||||
8
bundle/common/cache/cache.module.d.ts
vendored
Normal file
8
bundle/common/cache/cache.module.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DynamicModule } from '../interfaces';
|
||||
import { CacheModuleAsyncOptions, CacheModuleOptions } from './interfaces/cache-module.interface';
|
||||
export declare class CacheModule {
|
||||
static register(options?: CacheModuleOptions): DynamicModule;
|
||||
static registerAsync(options: CacheModuleAsyncOptions): DynamicModule;
|
||||
private static createAsyncProviders(options);
|
||||
private static createAsyncOptionsProvider(options);
|
||||
}
|
||||
60
bundle/common/cache/cache.module.js
vendored
Normal file
60
bundle/common/cache/cache.module.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const decorators_1 = require("../decorators");
|
||||
const cache_constants_1 = require("./cache.constants");
|
||||
const cache_providers_1 = require("./cache.providers");
|
||||
let CacheModule = CacheModule_1 = class CacheModule {
|
||||
static register(options = {}) {
|
||||
return {
|
||||
module: CacheModule_1,
|
||||
providers: [{ provide: cache_constants_1.CACHE_MODULE_OPTIONS, useValue: options }],
|
||||
};
|
||||
}
|
||||
static registerAsync(options) {
|
||||
return {
|
||||
module: CacheModule_1,
|
||||
imports: options.imports,
|
||||
providers: this.createAsyncProviders(options),
|
||||
};
|
||||
}
|
||||
static createAsyncProviders(options) {
|
||||
if (options.useExisting || options.useFactory) {
|
||||
return [this.createAsyncOptionsProvider(options)];
|
||||
}
|
||||
return [
|
||||
this.createAsyncOptionsProvider(options),
|
||||
{
|
||||
provide: options.useClass,
|
||||
useClass: options.useClass,
|
||||
},
|
||||
];
|
||||
}
|
||||
static createAsyncOptionsProvider(options) {
|
||||
if (options.useFactory) {
|
||||
return {
|
||||
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
|
||||
useFactory: options.useFactory,
|
||||
inject: options.inject || [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
provide: cache_constants_1.CACHE_MODULE_OPTIONS,
|
||||
useFactory: async (optionsFactory) => await optionsFactory.createCacheOptions(),
|
||||
inject: [options.useExisting || options.useClass],
|
||||
};
|
||||
}
|
||||
};
|
||||
CacheModule = CacheModule_1 = __decorate([
|
||||
decorators_1.Module({
|
||||
providers: [cache_providers_1.createCacheManager()],
|
||||
exports: [cache_constants_1.CACHE_MANAGER],
|
||||
})
|
||||
], CacheModule);
|
||||
exports.CacheModule = CacheModule;
|
||||
var CacheModule_1;
|
||||
2
bundle/common/cache/cache.providers.d.ts
vendored
Normal file
2
bundle/common/cache/cache.providers.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Provider } from '../interfaces';
|
||||
export declare function createCacheManager(): Provider;
|
||||
17
bundle/common/cache/cache.providers.js
vendored
Normal file
17
bundle/common/cache/cache.providers.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const load_package_util_1 = require("../utils/load-package.util");
|
||||
const cache_constants_1 = require("./cache.constants");
|
||||
const default_options_1 = require("./default-options");
|
||||
function createCacheManager() {
|
||||
return {
|
||||
provide: cache_constants_1.CACHE_MANAGER,
|
||||
useFactory: (options) => {
|
||||
const cacheManager = load_package_util_1.loadPackage('cache-manager', 'CacheModule');
|
||||
const memoryCache = cacheManager.caching(Object.assign({}, default_options_1.defaultCacheOptions, (options || {})));
|
||||
return memoryCache;
|
||||
},
|
||||
inject: [cache_constants_1.CACHE_MODULE_OPTIONS],
|
||||
};
|
||||
}
|
||||
exports.createCacheManager = createCacheManager;
|
||||
1
bundle/common/cache/decorators/cache-key.decorator.d.ts
vendored
Normal file
1
bundle/common/cache/decorators/cache-key.decorator.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const CacheKey: (key: string) => (target: object, key?: any, descriptor?: any) => any;
|
||||
5
bundle/common/cache/decorators/cache-key.decorator.js
vendored
Normal file
5
bundle/common/cache/decorators/cache-key.decorator.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const decorators_1 = require("../../decorators");
|
||||
const cache_constants_1 = require("../cache.constants");
|
||||
exports.CacheKey = (key) => decorators_1.ReflectMetadata(cache_constants_1.CACHE_KEY_METADATA, key);
|
||||
1
bundle/common/cache/decorators/index.d.ts
vendored
Normal file
1
bundle/common/cache/decorators/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './cache-key.decorator';
|
||||
6
bundle/common/cache/decorators/index.js
vendored
Normal file
6
bundle/common/cache/decorators/index.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./cache-key.decorator"));
|
||||
5
bundle/common/cache/default-options.d.ts
vendored
Normal file
5
bundle/common/cache/default-options.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare const defaultCacheOptions: {
|
||||
ttl: number;
|
||||
max: number;
|
||||
store: string;
|
||||
};
|
||||
7
bundle/common/cache/default-options.js
vendored
Normal file
7
bundle/common/cache/default-options.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultCacheOptions = {
|
||||
ttl: 5,
|
||||
max: 100,
|
||||
store: 'memory',
|
||||
};
|
||||
5
bundle/common/cache/index.d.ts
vendored
Normal file
5
bundle/common/cache/index.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { CACHE_MANAGER } from './cache.constants';
|
||||
export * from './cache.module';
|
||||
export * from './decorators';
|
||||
export * from './interceptors';
|
||||
export * from './interfaces';
|
||||
10
bundle/common/cache/index.js
vendored
Normal file
10
bundle/common/cache/index.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var cache_constants_1 = require("./cache.constants");
|
||||
exports.CACHE_MANAGER = cache_constants_1.CACHE_MANAGER;
|
||||
__export(require("./cache.module"));
|
||||
__export(require("./decorators"));
|
||||
__export(require("./interceptors"));
|
||||
11
bundle/common/cache/interceptors/cache.interceptor.d.ts
vendored
Normal file
11
bundle/common/cache/interceptors/cache.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { ExecutionContext, HttpServer, NestInterceptor } from '../../interfaces';
|
||||
export declare class CacheInterceptor implements NestInterceptor {
|
||||
protected readonly httpServer: HttpServer;
|
||||
protected readonly cacheManager: any;
|
||||
protected readonly reflector: any;
|
||||
protected readonly isHttpApp: boolean;
|
||||
constructor(httpServer: HttpServer, cacheManager: any, reflector: any);
|
||||
intercept(context: ExecutionContext, call$: Observable<any>): Promise<Observable<any>>;
|
||||
trackBy(context: ExecutionContext): string | undefined;
|
||||
}
|
||||
66
bundle/common/cache/interceptors/cache.interceptor.js
vendored
Normal file
66
bundle/common/cache/interceptors/cache.interceptor.js
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const rxjs_1 = require("rxjs");
|
||||
const operators_1 = require("rxjs/operators");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const cache_constants_1 = require("../cache.constants");
|
||||
// NOTE (external)
|
||||
// We need to deduplicate them here due to the circular dependency
|
||||
// between core and common packages
|
||||
const HTTP_SERVER_REF = 'HTTP_SERVER_REF';
|
||||
const REFLECTOR = 'Reflector';
|
||||
let CacheInterceptor = class CacheInterceptor {
|
||||
constructor(httpServer, cacheManager, reflector) {
|
||||
this.httpServer = httpServer;
|
||||
this.cacheManager = cacheManager;
|
||||
this.reflector = reflector;
|
||||
this.isHttpApp = httpServer && !!httpServer.getRequestMethod;
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const key = this.trackBy(context);
|
||||
if (!key) {
|
||||
return call$;
|
||||
}
|
||||
try {
|
||||
const value = await this.cacheManager.get(key);
|
||||
if (value) {
|
||||
return rxjs_1.of(value);
|
||||
}
|
||||
return call$.pipe(operators_1.tap(response => this.cacheManager.set(key, response)));
|
||||
}
|
||||
catch (_a) {
|
||||
return call$;
|
||||
}
|
||||
}
|
||||
trackBy(context) {
|
||||
if (!this.isHttpApp) {
|
||||
return this.reflector.get(cache_constants_1.CACHE_KEY_METADATA, context.getHandler());
|
||||
}
|
||||
const request = context.getArgByIndex(0);
|
||||
if (this.httpServer.getRequestMethod(request) !== 'GET') {
|
||||
return undefined;
|
||||
}
|
||||
return this.httpServer.getRequestUrl(request);
|
||||
}
|
||||
};
|
||||
CacheInterceptor = __decorate([
|
||||
decorators_1.Injectable(),
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(HTTP_SERVER_REF)),
|
||||
__param(1, decorators_1.Inject(cache_constants_1.CACHE_MANAGER)),
|
||||
__param(2, decorators_1.Inject(REFLECTOR)),
|
||||
__metadata("design:paramtypes", [Object, Object, Object])
|
||||
], CacheInterceptor);
|
||||
exports.CacheInterceptor = CacheInterceptor;
|
||||
1
bundle/common/cache/interceptors/index.d.ts
vendored
Normal file
1
bundle/common/cache/interceptors/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './cache.interceptor';
|
||||
6
bundle/common/cache/interceptors/index.js
vendored
Normal file
6
bundle/common/cache/interceptors/index.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./cache.interceptor"));
|
||||
17
bundle/common/cache/interfaces/cache-manager.interface.d.ts
vendored
Normal file
17
bundle/common/cache/interfaces/cache-manager.interface.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export interface LiteralObject {
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface CacheStore {
|
||||
set<T>(key: string, value: T): Promise<void> | void;
|
||||
get<T>(key: string): Promise<void> | void;
|
||||
del(key: string): void | Promise<void>;
|
||||
}
|
||||
export interface CacheStoreFactory {
|
||||
create(args: LiteralObject): CacheStore;
|
||||
}
|
||||
export interface CacheManagerOptions {
|
||||
store?: string | CacheStoreFactory;
|
||||
ttl?: number;
|
||||
max?: number;
|
||||
isCacheableValue?: (value: any) => boolean;
|
||||
}
|
||||
2
bundle/common/cache/interfaces/cache-manager.interface.js
vendored
Normal file
2
bundle/common/cache/interfaces/cache-manager.interface.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
14
bundle/common/cache/interfaces/cache-module.interface.d.ts
vendored
Normal file
14
bundle/common/cache/interfaces/cache-module.interface.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ModuleMetadata, Type } from '../../interfaces';
|
||||
import { CacheManagerOptions } from './cache-manager.interface';
|
||||
export interface CacheModuleOptions extends CacheManagerOptions {
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface CacheOptionsFactory {
|
||||
createCacheOptions(): Promise<CacheModuleOptions> | CacheModuleOptions;
|
||||
}
|
||||
export interface CacheModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
||||
useExisting?: Type<CacheOptionsFactory>;
|
||||
useClass?: Type<CacheOptionsFactory>;
|
||||
useFactory?: (...args: any[]) => Promise<CacheModuleOptions> | CacheModuleOptions;
|
||||
inject?: any[];
|
||||
}
|
||||
2
bundle/common/cache/interfaces/cache-module.interface.js
vendored
Normal file
2
bundle/common/cache/interfaces/cache-module.interface.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
2
bundle/common/cache/interfaces/index.d.ts
vendored
Normal file
2
bundle/common/cache/interfaces/index.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './cache-manager.interface';
|
||||
export * from './cache-module.interface';
|
||||
2
bundle/common/cache/interfaces/index.js
vendored
Normal file
2
bundle/common/cache/interfaces/index.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
2
bundle/common/constants.d.ts
vendored
2
bundle/common/constants.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
export declare const metadata: {
|
||||
export declare const METADATA: {
|
||||
MODULES: string;
|
||||
IMPORTS: string;
|
||||
COMPONENTS: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.metadata = {
|
||||
exports.METADATA = {
|
||||
MODULES: 'modules',
|
||||
IMPORTS: 'imports',
|
||||
COMPONENTS: 'components',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const deprecate = require("deprecate");
|
||||
const uuid = require("uuid/v4");
|
||||
/**
|
||||
* Defines the injectable class. This class can inject dependencies through constructor.
|
||||
* Those dependencies have to belong to the same module.
|
||||
@@ -55,10 +56,9 @@ function Interceptor() {
|
||||
return (target) => { };
|
||||
}
|
||||
exports.Interceptor = Interceptor;
|
||||
let offset = Math.random() * 100;
|
||||
function mixin(mixinClass) {
|
||||
Object.defineProperty(mixinClass, 'name', {
|
||||
value: JSON.stringify(offset++),
|
||||
value: uuid(),
|
||||
});
|
||||
Injectable()(mixinClass);
|
||||
return mixinClass;
|
||||
|
||||
@@ -6,7 +6,7 @@ export declare type ParamDecoratorEnhancer = ParameterDecorator;
|
||||
* Defines HTTP route param decorator
|
||||
* @param factory
|
||||
*/
|
||||
export declare function createParamDecorator(factory: CustomParamFactory, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | string)[]) => ParameterDecorator;
|
||||
export declare function createParamDecorator(factory: CustomParamFactory, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | any)[]) => ParameterDecorator;
|
||||
/**
|
||||
* Defines HTTP route param decorator
|
||||
* @deprecated
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const deprecate = require("deprecate");
|
||||
const uuid = require("uuid/v4");
|
||||
const constants_1 = require("../../constants");
|
||||
const shared_utils_1 = require("../../utils/shared.utils");
|
||||
const assignCustomMetadata = (args, paramtype, index, factory, data, ...pipes) => (Object.assign({}, args, { [`${paramtype}${constants_1.CUSTOM_ROUTE_AGRS_METADATA}:${index}`]: {
|
||||
@@ -9,18 +10,17 @@ const assignCustomMetadata = (args, paramtype, index, factory, data, ...pipes) =
|
||||
data,
|
||||
pipes,
|
||||
} }));
|
||||
const randomString = () => Math.random()
|
||||
.toString(36)
|
||||
.substring(2, 15);
|
||||
/**
|
||||
* Defines HTTP route param decorator
|
||||
* @param factory
|
||||
*/
|
||||
function createParamDecorator(factory, enhancers = []) {
|
||||
const paramtype = randomString() + randomString();
|
||||
const paramtype = uuid();
|
||||
return (data, ...pipes) => (target, key, index) => {
|
||||
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
||||
const hasParamData = shared_utils_1.isNil(data) || shared_utils_1.isString(data);
|
||||
const isPipe = pipe => pipe &&
|
||||
((shared_utils_1.isFunction(pipe) && pipe.prototype) || shared_utils_1.isFunction(pipe.transform));
|
||||
const hasParamData = shared_utils_1.isNil(data) || !isPipe(data);
|
||||
const paramData = hasParamData ? data : undefined;
|
||||
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
||||
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignCustomMetadata(args, paramtype, index, factory, paramData, ...paramPipes), target.constructor, key);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("reflect-metadata");
|
||||
const deprecate = require("deprecate");
|
||||
require("reflect-metadata");
|
||||
const constants_1 = require("../../constants");
|
||||
const invalid_module_config_exception_1 = require("./exceptions/invalid-module-config.exception");
|
||||
const metadataKeys = [
|
||||
constants_1.metadata.MODULES,
|
||||
constants_1.metadata.IMPORTS,
|
||||
constants_1.metadata.EXPORTS,
|
||||
constants_1.metadata.COMPONENTS,
|
||||
constants_1.metadata.CONTROLLERS,
|
||||
constants_1.metadata.PROVIDERS,
|
||||
constants_1.METADATA.MODULES,
|
||||
constants_1.METADATA.IMPORTS,
|
||||
constants_1.METADATA.EXPORTS,
|
||||
constants_1.METADATA.COMPONENTS,
|
||||
constants_1.METADATA.CONTROLLERS,
|
||||
constants_1.METADATA.PROVIDERS,
|
||||
];
|
||||
const validateKeys = (keys) => {
|
||||
const isKeyInvalid = key => metadataKeys.findIndex(k => k === key) < 0;
|
||||
@@ -54,8 +54,8 @@ function overrideModuleMetadata(moduleMetadata) {
|
||||
: moduleMetadata.components;
|
||||
}
|
||||
function showDeprecatedWarnings(moduleMetadata) {
|
||||
const modulesDeprecatedWarning = 'The "modules" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "imports" key instead.';
|
||||
const componentsDeprecatetWarning = 'The "components" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "providers" key instead.';
|
||||
moduleMetadata.modules && deprecate(modulesDeprecatedWarning);
|
||||
moduleMetadata.components && deprecate(componentsDeprecatetWarning);
|
||||
const MODULES_DEPRECATED_WARNING = 'The "modules" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "imports" key instead.';
|
||||
const COMPONENTS_DEPRECATED_WARNING = 'The "components" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "providers" key instead.';
|
||||
moduleMetadata.modules && deprecate(MODULES_DEPRECATED_WARNING);
|
||||
moduleMetadata.components && deprecate(COMPONENTS_DEPRECATED_WARNING);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class BadGatewayException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Bad Gateway') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.BAD_GATEWAY), http_status_enum_1.HttpStatus.BAD_GATEWAY);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class BadRequestException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Bad Request') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.BAD_REQUEST), http_status_enum_1.HttpStatus.BAD_REQUEST);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class ConflictException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Conflict') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.CONFLICT), http_status_enum_1.HttpStatus.CONFLICT);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class ForbiddenException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Forbidden') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.FORBIDDEN), http_status_enum_1.HttpStatus.FORBIDDEN);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class GatewayTimeoutException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Gateway Timeout') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.GATEWAY_TIMEOUT), http_status_enum_1.HttpStatus.GATEWAY_TIMEOUT);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class GoneException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Gone') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.GONE), http_status_enum_1.HttpStatus.GONE);
|
||||
|
||||
10
bundle/common/exceptions/im-a-teapot.exception.d.ts
vendored
Normal file
10
bundle/common/exceptions/im-a-teapot.exception.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { HttpException } from './http.exception';
|
||||
/**
|
||||
* Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot".
|
||||
* The resulting entity body MAY be short and stout.
|
||||
*
|
||||
* http://save418.com/
|
||||
*/
|
||||
export declare class ImATeapotException extends HttpException {
|
||||
constructor(message?: string | object | any, error?: string);
|
||||
}
|
||||
17
bundle/common/exceptions/im-a-teapot.exception.js
Normal file
17
bundle/common/exceptions/im-a-teapot.exception.js
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
/**
|
||||
* Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot".
|
||||
* The resulting entity body MAY be short and stout.
|
||||
*
|
||||
* http://save418.com/
|
||||
*/
|
||||
class ImATeapotException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'I\'m a teapot') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.I_AM_A_TEAPOT), http_status_enum_1.HttpStatus.I_AM_A_TEAPOT);
|
||||
}
|
||||
}
|
||||
exports.ImATeapotException = ImATeapotException;
|
||||
1
bundle/common/exceptions/index.d.ts
vendored
1
bundle/common/exceptions/index.d.ts
vendored
@@ -16,3 +16,4 @@ export * from './not-implemented.exception';
|
||||
export * from './bad-gateway.exception';
|
||||
export * from './service-unavailable.exception';
|
||||
export * from './gateway-timeout.exception';
|
||||
export * from './im-a-teapot.exception';
|
||||
|
||||
@@ -21,3 +21,4 @@ __export(require("./not-implemented.exception"));
|
||||
__export(require("./bad-gateway.exception"));
|
||||
__export(require("./service-unavailable.exception"));
|
||||
__export(require("./gateway-timeout.exception"));
|
||||
__export(require("./im-a-teapot.exception"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class InternalServerErrorException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Internal Server Error') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.INTERNAL_SERVER_ERROR), http_status_enum_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class MethodNotAllowedException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Method Not Allowed') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.METHOD_NOT_ALLOWED), http_status_enum_1.HttpStatus.METHOD_NOT_ALLOWED);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class NotAcceptableException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Not Acceptable') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.NOT_ACCEPTABLE), http_status_enum_1.HttpStatus.NOT_ACCEPTABLE);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class NotFoundException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Not Found') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.NOT_FOUND), http_status_enum_1.HttpStatus.NOT_FOUND);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class NotImplementedException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Not Implemented') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.NOT_IMPLEMENTED), http_status_enum_1.HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class PayloadTooLargeException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Payload Too Large') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.PAYLOAD_TOO_LARGE), http_status_enum_1.HttpStatus.PAYLOAD_TOO_LARGE);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class RequestTimeoutException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Request Timeout') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.REQUEST_TIMEOUT), http_status_enum_1.HttpStatus.REQUEST_TIMEOUT);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class ServiceUnavailableException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Service Unavailable') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.SERVICE_UNAVAILABLE), http_status_enum_1.HttpStatus.SERVICE_UNAVAILABLE);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class UnauthorizedException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Unauthorized') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.UNAUTHORIZED), http_status_enum_1.HttpStatus.UNAUTHORIZED);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class UnprocessableEntityException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Unprocessable Entity') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.UNPROCESSABLE_ENTITY), http_status_enum_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http_exception_1 = require("./http.exception");
|
||||
const http_status_enum_1 = require("../enums/http-status.enum");
|
||||
const http_exception_body_util_1 = require("./../utils/http-exception-body.util");
|
||||
const http_exception_body_util_1 = require("../utils/http-exception-body.util");
|
||||
class UnsupportedMediaTypeException extends http_exception_1.HttpException {
|
||||
constructor(message, error = 'Unsupported Media Type') {
|
||||
super(http_exception_body_util_1.createHttpExceptionBody(message, error, http_status_enum_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE), http_status_enum_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
||||
|
||||
1
bundle/common/files/files.constants.d.ts
vendored
Normal file
1
bundle/common/files/files.constants.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const MULTER_MODULE_OPTIONS = "MULTER_MODULE_OPTIONS";
|
||||
3
bundle/common/files/files.constants.js
Normal file
3
bundle/common/files/files.constants.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MULTER_MODULE_OPTIONS = 'MULTER_MODULE_OPTIONS';
|
||||
3
bundle/common/files/index.d.ts
vendored
Normal file
3
bundle/common/files/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './interceptors';
|
||||
export * from './interfaces';
|
||||
export * from './multer.module';
|
||||
7
bundle/common/files/index.js
Normal file
7
bundle/common/files/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./interceptors"));
|
||||
__export(require("./multer.module"));
|
||||
2
bundle/common/files/interceptors/file-fields.interceptor.d.ts
vendored
Normal file
2
bundle/common/files/interceptors/file-fields.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MulterField, MulterOptions } from '../../interfaces/external/multer-options.interface';
|
||||
export declare function FileFieldsInterceptor(uploadFields: MulterField[], localOptions?: MulterOptions): any;
|
||||
45
bundle/common/files/interceptors/file-fields.interceptor.js
Normal file
45
bundle/common/files/interceptors/file-fields.interceptor.js
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const component_decorator_1 = require("../../decorators/core/component.decorator");
|
||||
const files_constants_1 = require("../files.constants");
|
||||
const multer_utils_1 = require("../multer/multer.utils");
|
||||
function FileFieldsInterceptor(uploadFields, localOptions) {
|
||||
let MixinInterceptor = class MixinInterceptor {
|
||||
constructor(options = {}) {
|
||||
this.upload = multer(Object.assign({}, options, localOptions));
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const ctx = context.switchToHttp();
|
||||
await new Promise((resolve, reject) => this.upload.fields(uploadFields)(ctx.getRequest(), ctx.getResponse(), err => {
|
||||
if (err) {
|
||||
const error = multer_utils_1.transformException(err);
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
};
|
||||
MixinInterceptor = __decorate([
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MixinInterceptor);
|
||||
const Interceptor = component_decorator_1.mixin(MixinInterceptor);
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FileFieldsInterceptor = FileFieldsInterceptor;
|
||||
2
bundle/common/files/interceptors/file.interceptor.d.ts
vendored
Normal file
2
bundle/common/files/interceptors/file.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MulterOptions } from '../../interfaces/external/multer-options.interface';
|
||||
export declare function FileInterceptor(fieldName: string, localOptions?: MulterOptions): any;
|
||||
45
bundle/common/files/interceptors/file.interceptor.js
Normal file
45
bundle/common/files/interceptors/file.interceptor.js
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const component_decorator_1 = require("../../decorators/core/component.decorator");
|
||||
const files_constants_1 = require("../files.constants");
|
||||
const multer_utils_1 = require("../multer/multer.utils");
|
||||
function FileInterceptor(fieldName, localOptions) {
|
||||
let MixinInterceptor = class MixinInterceptor {
|
||||
constructor(options = {}) {
|
||||
this.upload = multer(Object.assign({}, options, localOptions));
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const ctx = context.switchToHttp();
|
||||
await new Promise((resolve, reject) => this.upload.single(fieldName)(ctx.getRequest(), ctx.getResponse(), err => {
|
||||
if (err) {
|
||||
const error = multer_utils_1.transformException(err);
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
};
|
||||
MixinInterceptor = __decorate([
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MixinInterceptor);
|
||||
const Interceptor = component_decorator_1.mixin(MixinInterceptor);
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FileInterceptor = FileInterceptor;
|
||||
2
bundle/common/files/interceptors/files.interceptor.d.ts
vendored
Normal file
2
bundle/common/files/interceptors/files.interceptor.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MulterOptions } from '../../interfaces/external/multer-options.interface';
|
||||
export declare function FilesInterceptor(fieldName: string, maxCount?: number, localOptions?: MulterOptions): any;
|
||||
45
bundle/common/files/interceptors/files.interceptor.js
Normal file
45
bundle/common/files/interceptors/files.interceptor.js
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const multer = require("multer");
|
||||
const decorators_1 = require("../../decorators");
|
||||
const component_decorator_1 = require("../../decorators/core/component.decorator");
|
||||
const files_constants_1 = require("../files.constants");
|
||||
const multer_utils_1 = require("../multer/multer.utils");
|
||||
function FilesInterceptor(fieldName, maxCount, localOptions) {
|
||||
let MixinInterceptor = class MixinInterceptor {
|
||||
constructor(options = {}) {
|
||||
this.upload = multer(Object.assign({}, options, localOptions));
|
||||
}
|
||||
async intercept(context, call$) {
|
||||
const ctx = context.switchToHttp();
|
||||
await new Promise((resolve, reject) => this.upload.array(fieldName, maxCount)(ctx.getRequest(), ctx.getResponse(), err => {
|
||||
if (err) {
|
||||
const error = multer_utils_1.transformException(err);
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
}));
|
||||
return call$;
|
||||
}
|
||||
};
|
||||
MixinInterceptor = __decorate([
|
||||
__param(0, decorators_1.Optional()),
|
||||
__param(0, decorators_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MixinInterceptor);
|
||||
const Interceptor = component_decorator_1.mixin(MixinInterceptor);
|
||||
return Interceptor;
|
||||
}
|
||||
exports.FilesInterceptor = FilesInterceptor;
|
||||
8
bundle/common/files/interceptors/index.js
Normal file
8
bundle/common/files/interceptors/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./file-fields.interceptor"));
|
||||
__export(require("./file.interceptor"));
|
||||
__export(require("./files.interceptor"));
|
||||
13
bundle/common/files/interfaces/files-upload-module.interface.d.ts
vendored
Normal file
13
bundle/common/files/interfaces/files-upload-module.interface.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
||||
import { MulterOptions } from '../../interfaces/external/multer-options.interface';
|
||||
export interface MulterModuleOptions extends MulterOptions {
|
||||
}
|
||||
export interface MulterOptionsFactory {
|
||||
createMulterOptions(): Promise<MulterModuleOptions> | MulterModuleOptions;
|
||||
}
|
||||
export interface MulterModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
||||
useExisting?: Type<MulterOptionsFactory>;
|
||||
useClass?: Type<MulterOptionsFactory>;
|
||||
useFactory?: (...args: any[]) => Promise<MulterModuleOptions> | MulterModuleOptions;
|
||||
inject?: any[];
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
bundle/common/files/interfaces/index.d.ts
vendored
Normal file
1
bundle/common/files/interfaces/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './files-upload-module.interface';
|
||||
2
bundle/common/files/interfaces/index.js
Normal file
2
bundle/common/files/interfaces/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
8
bundle/common/files/multer.module.d.ts
vendored
Normal file
8
bundle/common/files/multer.module.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DynamicModule } from '@nestjs/common';
|
||||
import { MulterModuleAsyncOptions, MulterModuleOptions } from './interfaces/files-upload-module.interface';
|
||||
export declare class MulterModule {
|
||||
static register(options?: MulterModuleOptions): DynamicModule;
|
||||
static registerAsync(options: MulterModuleAsyncOptions): DynamicModule;
|
||||
private static createAsyncProviders(options);
|
||||
private static createAsyncOptionsProvider(options);
|
||||
}
|
||||
58
bundle/common/files/multer.module.js
Normal file
58
bundle/common/files/multer.module.js
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common_1 = require("@nestjs/common");
|
||||
const files_constants_1 = require("./files.constants");
|
||||
let MulterModule = MulterModule_1 = class MulterModule {
|
||||
static register(options = {}) {
|
||||
return {
|
||||
module: MulterModule_1,
|
||||
providers: [{ provide: files_constants_1.MULTER_MODULE_OPTIONS, useValue: options }],
|
||||
exports: [files_constants_1.MULTER_MODULE_OPTIONS],
|
||||
};
|
||||
}
|
||||
static registerAsync(options) {
|
||||
return {
|
||||
module: MulterModule_1,
|
||||
imports: options.imports,
|
||||
providers: this.createAsyncProviders(options),
|
||||
exports: [files_constants_1.MULTER_MODULE_OPTIONS],
|
||||
};
|
||||
}
|
||||
static createAsyncProviders(options) {
|
||||
if (options.useExisting || options.useFactory) {
|
||||
return [this.createAsyncOptionsProvider(options)];
|
||||
}
|
||||
return [
|
||||
this.createAsyncOptionsProvider(options),
|
||||
{
|
||||
provide: options.useClass,
|
||||
useClass: options.useClass,
|
||||
},
|
||||
];
|
||||
}
|
||||
static createAsyncOptionsProvider(options) {
|
||||
if (options.useFactory) {
|
||||
return {
|
||||
provide: files_constants_1.MULTER_MODULE_OPTIONS,
|
||||
useFactory: options.useFactory,
|
||||
inject: options.inject || [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
provide: files_constants_1.MULTER_MODULE_OPTIONS,
|
||||
useFactory: async (optionsFactory) => await optionsFactory.createMulterOptions(),
|
||||
inject: [options.useExisting || options.useClass],
|
||||
};
|
||||
}
|
||||
};
|
||||
MulterModule = MulterModule_1 = __decorate([
|
||||
common_1.Module({})
|
||||
], MulterModule);
|
||||
exports.MulterModule = MulterModule;
|
||||
var MulterModule_1;
|
||||
9
bundle/common/files/multer/multer.constants.d.ts
vendored
Normal file
9
bundle/common/files/multer/multer.constants.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export declare const multerExceptions: {
|
||||
LIMIT_PART_COUNT: string;
|
||||
LIMIT_FILE_SIZE: string;
|
||||
LIMIT_FILE_COUNT: string;
|
||||
LIMIT_FIELD_KEY: string;
|
||||
LIMIT_FIELD_VALUE: string;
|
||||
LIMIT_FIELD_COUNT: string;
|
||||
LIMIT_UNEXPECTED_FILE: string;
|
||||
};
|
||||
11
bundle/common/files/multer/multer.constants.js
Normal file
11
bundle/common/files/multer/multer.constants.js
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.multerExceptions = {
|
||||
LIMIT_PART_COUNT: 'Too many parts',
|
||||
LIMIT_FILE_SIZE: 'File too large',
|
||||
LIMIT_FILE_COUNT: 'Too many files',
|
||||
LIMIT_FIELD_KEY: 'Field name too long',
|
||||
LIMIT_FIELD_VALUE: 'Field value too long',
|
||||
LIMIT_FIELD_COUNT: 'Too many fields',
|
||||
LIMIT_UNEXPECTED_FILE: 'Unexpected field',
|
||||
};
|
||||
2
bundle/common/files/multer/multer.utils.d.ts
vendored
Normal file
2
bundle/common/files/multer/multer.utils.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { BadRequestException, PayloadTooLargeException } from '../../exceptions';
|
||||
export declare function transformException(error: Error | undefined): Error | BadRequestException | PayloadTooLargeException;
|
||||
22
bundle/common/files/multer/multer.utils.js
Normal file
22
bundle/common/files/multer/multer.utils.js
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const exceptions_1 = require("../../exceptions");
|
||||
const multer_constants_1 = require("./multer.constants");
|
||||
function transformException(error) {
|
||||
if (!error || error instanceof exceptions_1.HttpException) {
|
||||
return error;
|
||||
}
|
||||
switch (error.message) {
|
||||
case multer_constants_1.multerExceptions.LIMIT_FILE_SIZE:
|
||||
return new exceptions_1.PayloadTooLargeException(error.message);
|
||||
case multer_constants_1.multerExceptions.LIMIT_FILE_COUNT:
|
||||
case multer_constants_1.multerExceptions.LIMIT_FIELD_KEY:
|
||||
case multer_constants_1.multerExceptions.LIMIT_FIELD_VALUE:
|
||||
case multer_constants_1.multerExceptions.LIMIT_FIELD_COUNT:
|
||||
case multer_constants_1.multerExceptions.LIMIT_UNEXPECTED_FILE:
|
||||
case multer_constants_1.multerExceptions.LIMIT_PART_COUNT:
|
||||
return new exceptions_1.BadRequestException(error.message);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
exports.transformException = transformException;
|
||||
1
bundle/common/http/http.constants.d.ts
vendored
1
bundle/common/http/http.constants.d.ts
vendored
@@ -1 +1,2 @@
|
||||
export declare const AXIOS_INSTANCE_TOKEN = "AXIOS_INSTANCE_TOKEN";
|
||||
export declare const HTTP_MODULE_ID = "HTTP_MODULE_ID";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN';
|
||||
exports.HTTP_MODULE_ID = 'HTTP_MODULE_ID';
|
||||
|
||||
@@ -8,25 +8,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const axios_1 = require("axios");
|
||||
const module_decorator_1 = require("../decorators/modules/module.decorator");
|
||||
const random_string_generator_util_1 = require("../utils/random-string-generator.util");
|
||||
const http_constants_1 = require("./http.constants");
|
||||
const http_service_1 = require("./http.service");
|
||||
let HttpModule = HttpModule_1 = class HttpModule {
|
||||
static register(config) {
|
||||
return {
|
||||
module: HttpModule_1,
|
||||
providers: [{
|
||||
providers: [
|
||||
{
|
||||
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
||||
useValue: axios_1.default.create(config),
|
||||
}],
|
||||
},
|
||||
{
|
||||
provide: http_constants_1.HTTP_MODULE_ID,
|
||||
useValue: random_string_generator_util_1.randomStringGenerator(),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
};
|
||||
HttpModule = HttpModule_1 = __decorate([
|
||||
module_decorator_1.Module({
|
||||
providers: [http_service_1.HttpService, {
|
||||
providers: [
|
||||
http_service_1.HttpService,
|
||||
{
|
||||
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
||||
useValue: axios_1.default,
|
||||
}],
|
||||
},
|
||||
],
|
||||
exports: [http_service_1.HttpService],
|
||||
})
|
||||
], HttpModule);
|
||||
|
||||
6
bundle/common/index.d.ts
vendored
6
bundle/common/index.d.ts
vendored
@@ -1,9 +1,11 @@
|
||||
export * from './cache';
|
||||
export * from './decorators';
|
||||
export * from './enums';
|
||||
export * from './exceptions';
|
||||
export * from './files';
|
||||
export * from './http';
|
||||
export * from './interceptors';
|
||||
export { ArgumentMetadata, ArgumentsHost, CanActivate, DynamicModule, ExceptionFilter, ExecutionContext, ForwardReference, HttpServer, HttpServerFactory, INestApplication, INestApplicationContext, INestExpressApplication, INestFastifyApplication, INestMicroservice, MiddlewareConsumer, MiddlewareFunction, NestInterceptor, NestMiddleware, NestModule, OnModuleDestroy, OnModuleInit, Paramtype, PipeTransform, Provider, RpcExceptionFilter, Type, WebSocketAdapter, WsExceptionFilter } from './interfaces';
|
||||
export { ArgumentMetadata, ArgumentsHost, CanActivate, DynamicModule, ExceptionFilter, ExecutionContext, ForwardReference, HttpServer, HttpServerFactory, INestApplication, INestApplicationContext, INestExpressApplication, INestFastifyApplication, INestMicroservice, MiddlewareConsumer, MiddlewareFunction, NestInterceptor, NestMiddleware, NestModule, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, Paramtype, PipeTransform, Provider, RpcExceptionFilter, Type, WebSocketAdapter, WsExceptionFilter } from './interfaces';
|
||||
export * from './pipes';
|
||||
export * from './serializer';
|
||||
export * from './services/logger.service';
|
||||
export * from './utils';
|
||||
|
||||
@@ -9,11 +9,13 @@ function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./cache"));
|
||||
__export(require("./decorators"));
|
||||
__export(require("./enums"));
|
||||
__export(require("./exceptions"));
|
||||
__export(require("./files"));
|
||||
__export(require("./http"));
|
||||
__export(require("./interceptors"));
|
||||
__export(require("./pipes"));
|
||||
__export(require("./serializer"));
|
||||
__export(require("./services/logger.service"));
|
||||
__export(require("./utils"));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ArgumentsHost } from './../features/arguments-host.interface';
|
||||
import { ArgumentsHost } from '../features/arguments-host.interface';
|
||||
export interface ExceptionFilter<T = any> {
|
||||
catch(exception: T, host: ArgumentsHost): any;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { ArgumentsHost } from './../features/arguments-host.interface';
|
||||
import { ArgumentsHost } from '../features/arguments-host.interface';
|
||||
export interface RpcExceptionFilter<T = any, R = any> {
|
||||
catch(exception: T, host: ArgumentsHost): Observable<R>;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ArgumentsHost } from './../features/arguments-host.interface';
|
||||
import { ArgumentsHost } from '../features/arguments-host.interface';
|
||||
export interface WsExceptionFilter<T = any> {
|
||||
catch(exception: T, host: ArgumentsHost): any;
|
||||
}
|
||||
|
||||
41
bundle/common/interfaces/external/class-transform-options.interface.d.ts
vendored
Normal file
41
bundle/common/interfaces/external/class-transform-options.interface.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Options to be passed during transformation.
|
||||
* @see https://github.com/typestack/class-transformer
|
||||
*/
|
||||
export interface ClassTransformOptions {
|
||||
/**
|
||||
* Exclusion strategy. By default exposeAll is used, which means that it will expose all properties are transformed
|
||||
* by default.
|
||||
*/
|
||||
strategy?: 'excludeAll' | 'exposeAll';
|
||||
/**
|
||||
* Only properties with given groups gonna be transformed.
|
||||
*/
|
||||
groups?: string[];
|
||||
/**
|
||||
* Only properties with "since" > version < "until" gonna be transformed.
|
||||
*/
|
||||
version?: number;
|
||||
/**
|
||||
* Excludes properties with the given prefixes. For example, if you mark your private properties with "_" and "__"
|
||||
* you can set this option's value to ["_", "__"] and all private properties will be skipped.
|
||||
* This works only for "exposeAll" strategy.
|
||||
*/
|
||||
excludePrefixes?: string[];
|
||||
/**
|
||||
* If set to true then class transformer will ignore all @Expose and @Exclude decorators and what inside them.
|
||||
* This option is useful if you want to kinda clone your object but do not apply decorators affects.
|
||||
*/
|
||||
ignoreDecorators?: boolean;
|
||||
/**
|
||||
* Target maps allows to set a Types of the transforming object without using @Type decorator.
|
||||
* This is useful when you are transforming external classes, or if you already have type metadata for
|
||||
* objects and you don't want to set it up again.
|
||||
*/
|
||||
targetMaps?: any[];
|
||||
/**
|
||||
* If set to true then class transformer will perform a circular check. (circular check is turned off by default)
|
||||
* This option is useful when you know for sure that your types might have a circular dependency.
|
||||
*/
|
||||
enableCircularCheck?: boolean;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user