From f84377f107fa6a0aa2e9e7fab9fb10ab8b6bd379 Mon Sep 17 00:00:00 2001 From: zzy Date: Thu, 6 Dec 2018 13:34:22 +0800 Subject: [PATCH] init --- .gitignore | 68 +++++ .prettierrc | 4 + LICENSE | 21 ++ README.md | 57 +++++ dist/index.d.ts | 3 + dist/index.js | 7 + dist/rabbitmq-client.provider.d.ts | 12 + dist/rabbitmq-client.provider.js | 16 ++ dist/rabbitmq.constants.d.ts | 2 + dist/rabbitmq.constants.js | 4 + dist/rabbitmq.interface.d.ts | 11 + dist/rabbitmq.interface.js | 2 + dist/rabbitmq.module.d.ts | 6 + dist/rabbitmq.module.js | 46 ++++ dist/rabbitmq.service.d.ts | 6 + dist/rabbitmq.service.js | 31 +++ index.d.ts | 1 + index.js | 6 + index.ts | 1 + lib/index.ts | 3 + lib/rabbitmq-client.provider.ts | 16 ++ lib/rabbitmq.constants.ts | 2 + lib/rabbitmq.interface.ts | 13 + lib/rabbitmq.module.ts | 36 +++ lib/rabbitmq.service.ts | 13 + package.json | 36 +++ tsconfig.json | 24 ++ tsconfig.spec.json | 7 + tslint.json | 55 ++++ webpack.config.js | 34 +++ yarn.lock | 390 +++++++++++++++++++++++++++++ 31 files changed, 933 insertions(+) create mode 100644 .gitignore create mode 100644 .prettierrc create mode 100644 LICENSE create mode 100644 README.md create mode 100644 dist/index.d.ts create mode 100644 dist/index.js create mode 100644 dist/rabbitmq-client.provider.d.ts create mode 100644 dist/rabbitmq-client.provider.js create mode 100644 dist/rabbitmq.constants.d.ts create mode 100644 dist/rabbitmq.constants.js create mode 100644 dist/rabbitmq.interface.d.ts create mode 100644 dist/rabbitmq.interface.js create mode 100644 dist/rabbitmq.module.d.ts create mode 100644 dist/rabbitmq.module.js create mode 100644 dist/rabbitmq.service.d.ts create mode 100644 dist/rabbitmq.service.js create mode 100644 index.d.ts create mode 100644 index.js create mode 100644 index.ts create mode 100644 lib/index.ts create mode 100644 lib/rabbitmq-client.provider.ts create mode 100644 lib/rabbitmq.constants.ts create mode 100644 lib/rabbitmq.interface.ts create mode 100644 lib/rabbitmq.module.ts create mode 100644 lib/rabbitmq.service.ts create mode 100644 package.json create mode 100644 tsconfig.json create mode 100644 tsconfig.spec.json create mode 100644 tslint.json create mode 100644 webpack.config.js create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..398d036 --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# upload +uploads/ + +.DS_Store +.gulp-cache +src/test +.vscode +logs/ +*.thrift +*.sql \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..dcb7279 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "trailingComma": "all" +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0c33994 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 KnowYourself + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e9d666 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ + +# Nestjs Rabbitmq +Rabbitmq component for NestJs. + + +### Installation + +**Yarn** +```bash +yarn add nestjs-rabbitmq +``` + +**NPM** +```bash +npm install nestjs-rabbitmq --save +``` + +### Getting Started +Let's import the RabbitMqModule in `app.module.ts` + +```typescript +import { Module } from '@nestjs/common'; +import { RabbitMqModule} from 'nestjs-rabbitmq' + +@Module({ + imports: [ + RabbitMqModule.forRoot(options) + ], +}) +export class AppModule {} +``` +With Async +```typescript +import { Module } from '@nestjs/common'; +import { RabbitMqModule} from 'nestjs-rabbitmq' + +@Module({ + imports: [ + RabbitMqModule.forRootAsync({ + useFactory: (configService: ConfigService) => configService.get('rabbitmq'), // or use async method + //useFactory: async (configService: ConfigService) => configService.get('rabbitmq'), + inject:[ConfigService] + }), + ], +}) +export class AppModule {} +``` +Options +```typescript +interface RabbitMqModuleOptions { + user?: string, //Default guest + passwd?: string, //Default guest + host?: string, //Default localhost + port?: number //Default 5672 +} +``` +That's it! \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..b8b20aa --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +export * from './rabbitmq.interface'; +export * from './rabbitmq.module'; +export * from './rabbitmq.service'; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..d9f58ad --- /dev/null +++ b/dist/index.js @@ -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("./rabbitmq.module")); +__export(require("./rabbitmq.service")); diff --git a/dist/rabbitmq-client.provider.d.ts b/dist/rabbitmq-client.provider.d.ts new file mode 100644 index 0000000..10220c1 --- /dev/null +++ b/dist/rabbitmq-client.provider.d.ts @@ -0,0 +1,12 @@ +import { RabbitMqModuleOptions, RabbitMqModuleAsyncOptions } from "./rabbitmq.interface"; +import * as amqp from 'amqp-connection-manager'; +export declare const createClient: () => { + provide: symbol; + useFactory: (options: RabbitMqModuleOptions) => amqp.AmqpConnectionManager; + inject: symbol[]; +}; +export declare const createAsyncClientOptions: (options: RabbitMqModuleAsyncOptions) => { + provide: symbol; + useFactory: (...args: any[]) => RabbitMqModuleOptions | Promise; + inject: any[]; +}; diff --git a/dist/rabbitmq-client.provider.js b/dist/rabbitmq-client.provider.js new file mode 100644 index 0000000..7b2031a --- /dev/null +++ b/dist/rabbitmq-client.provider.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const rabbitmq_constants_1 = require("./rabbitmq.constants"); +const amqp = require("amqp-connection-manager"); +exports.createClient = () => ({ + provide: rabbitmq_constants_1.RABBITMQ_CLIENT, + useFactory: (options) => { + return amqp.connect([`amqp://${options.user || 'guest'}:${options.passwd || 'guest'}@${options.host || 'localhost'}:${options.port || 5672}`]); + }, + inject: [rabbitmq_constants_1.RABBITMQ_MODULE_OPTIONS] +}); +exports.createAsyncClientOptions = (options) => ({ + provide: rabbitmq_constants_1.RABBITMQ_MODULE_OPTIONS, + useFactory: options.useFactory, + inject: options.inject +}); diff --git a/dist/rabbitmq.constants.d.ts b/dist/rabbitmq.constants.d.ts new file mode 100644 index 0000000..208488a --- /dev/null +++ b/dist/rabbitmq.constants.d.ts @@ -0,0 +1,2 @@ +export declare const RABBITMQ_MODULE_OPTIONS: unique symbol; +export declare const RABBITMQ_CLIENT: unique symbol; diff --git a/dist/rabbitmq.constants.js b/dist/rabbitmq.constants.js new file mode 100644 index 0000000..f05008a --- /dev/null +++ b/dist/rabbitmq.constants.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RABBITMQ_MODULE_OPTIONS = Symbol('RABBITMQ_MODULE_OPTIONS'); +exports.RABBITMQ_CLIENT = Symbol('RABBITMQ_CLIENT'); diff --git a/dist/rabbitmq.interface.d.ts b/dist/rabbitmq.interface.d.ts new file mode 100644 index 0000000..15b4bf3 --- /dev/null +++ b/dist/rabbitmq.interface.d.ts @@ -0,0 +1,11 @@ +import { ModuleMetadata } from "@nestjs/common/interfaces"; +export interface RabbitMqModuleOptions { + user?: string; + passwd?: string; + host?: string; + port?: number; +} +export interface RabbitMqModuleAsyncOptions extends Pick { + useFactory?: (...args: any[]) => RabbitMqModuleOptions | Promise; + inject?: any[]; +} diff --git a/dist/rabbitmq.interface.js b/dist/rabbitmq.interface.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/rabbitmq.interface.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/rabbitmq.module.d.ts b/dist/rabbitmq.module.d.ts new file mode 100644 index 0000000..ce85d46 --- /dev/null +++ b/dist/rabbitmq.module.d.ts @@ -0,0 +1,6 @@ +import { DynamicModule } from '@nestjs/common'; +import { RabbitMqModuleOptions, RabbitMqModuleAsyncOptions } from './rabbitmq.interface'; +export declare class RabbitMqModule { + static forRoot(options: RabbitMqModuleOptions): DynamicModule; + static forRootSync(options: RabbitMqModuleAsyncOptions): DynamicModule; +} diff --git a/dist/rabbitmq.module.js b/dist/rabbitmq.module.js new file mode 100644 index 0000000..c661c14 --- /dev/null +++ b/dist/rabbitmq.module.js @@ -0,0 +1,46 @@ +"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 }); +var RabbitMqModule_1; +const common_1 = require("@nestjs/common"); +const rabbitmq_constants_1 = require("./rabbitmq.constants"); +const rabbitmq_service_1 = require("./rabbitmq.service"); +const rabbitmq_client_provider_1 = require("./rabbitmq-client.provider"); +let RabbitMqModule = RabbitMqModule_1 = class RabbitMqModule { + static forRoot(options) { + return { + module: RabbitMqModule_1, + providers: [ + rabbitmq_client_provider_1.createClient(), + { + provide: rabbitmq_constants_1.RABBITMQ_MODULE_OPTIONS, + useValue: options + } + ], + exports: [rabbitmq_service_1.RabbitMqService] + }; + } + static forRootSync(options) { + return { + module: RabbitMqModule_1, + providers: [ + rabbitmq_client_provider_1.createClient(), + rabbitmq_client_provider_1.createAsyncClientOptions(options), + ], + exports: [rabbitmq_service_1.RabbitMqService] + }; + } +}; +RabbitMqModule = RabbitMqModule_1 = __decorate([ + common_1.Global(), + common_1.Module({ + providers: [rabbitmq_service_1.RabbitMqService], + exports: [rabbitmq_service_1.RabbitMqService] + }) +], RabbitMqModule); +exports.RabbitMqModule = RabbitMqModule; diff --git a/dist/rabbitmq.service.d.ts b/dist/rabbitmq.service.d.ts new file mode 100644 index 0000000..4e774c8 --- /dev/null +++ b/dist/rabbitmq.service.d.ts @@ -0,0 +1,6 @@ +import * as amqp from 'amqp-connection-manager'; +export declare class RabbitMqService { + private readonly client; + constructor(client: amqp.AmqpConnectionManager); + getClient(): amqp.AmqpConnectionManager; +} diff --git a/dist/rabbitmq.service.js b/dist/rabbitmq.service.js new file mode 100644 index 0000000..4eeb933 --- /dev/null +++ b/dist/rabbitmq.service.js @@ -0,0 +1,31 @@ +"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 common_1 = require("@nestjs/common"); +const rabbitmq_constants_1 = require("./rabbitmq.constants"); +const amqp = require("amqp-connection-manager"); +let RabbitMqService = class RabbitMqService { + constructor(client) { + this.client = client; + } + getClient() { + return this.client; + } +}; +RabbitMqService = __decorate([ + common_1.Injectable(), + __param(0, common_1.Inject(rabbitmq_constants_1.RABBITMQ_CLIENT)), + __metadata("design:paramtypes", [Object]) +], RabbitMqService); +exports.RabbitMqService = RabbitMqService; diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..2118b14 --- /dev/null +++ b/index.d.ts @@ -0,0 +1 @@ +export * from "./dist"; \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..9368dd3 --- /dev/null +++ b/index.js @@ -0,0 +1,6 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +exports.__esModule = true; +__export(require("./dist")); diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..a25cfd4 --- /dev/null +++ b/index.ts @@ -0,0 +1 @@ +export * from './dist' \ No newline at end of file diff --git a/lib/index.ts b/lib/index.ts new file mode 100644 index 0000000..2e90215 --- /dev/null +++ b/lib/index.ts @@ -0,0 +1,3 @@ +export * from './rabbitmq.interface' +export * from './rabbitmq.module' +export * from './rabbitmq.service' \ No newline at end of file diff --git a/lib/rabbitmq-client.provider.ts b/lib/rabbitmq-client.provider.ts new file mode 100644 index 0000000..de8210e --- /dev/null +++ b/lib/rabbitmq-client.provider.ts @@ -0,0 +1,16 @@ +import { RabbitMqModuleOptions, RabbitMqModuleAsyncOptions } from "./rabbitmq.interface"; +import { RABBITMQ_CLIENT, RABBITMQ_MODULE_OPTIONS } from './rabbitmq.constants'; +import * as amqp from 'amqp-connection-manager' +export const createClient = () => ({ + provide: RABBITMQ_CLIENT, + useFactory:(options: RabbitMqModuleOptions) => { + return amqp.connect([`amqp://${options.user || 'guest'}:${options.passwd || 'guest'}@${options.host || 'localhost'}:${options.port || 5672}`]) + }, + inject:[RABBITMQ_MODULE_OPTIONS] +}) + +export const createAsyncClientOptions = (options: RabbitMqModuleAsyncOptions) => ({ + provide: RABBITMQ_MODULE_OPTIONS, + useFactory: options.useFactory, + inject: options.inject +}) \ No newline at end of file diff --git a/lib/rabbitmq.constants.ts b/lib/rabbitmq.constants.ts new file mode 100644 index 0000000..b8de605 --- /dev/null +++ b/lib/rabbitmq.constants.ts @@ -0,0 +1,2 @@ +export const RABBITMQ_MODULE_OPTIONS = Symbol('RABBITMQ_MODULE_OPTIONS') +export const RABBITMQ_CLIENT = Symbol('RABBITMQ_CLIENT') \ No newline at end of file diff --git a/lib/rabbitmq.interface.ts b/lib/rabbitmq.interface.ts new file mode 100644 index 0000000..215e40f --- /dev/null +++ b/lib/rabbitmq.interface.ts @@ -0,0 +1,13 @@ +import { ModuleMetadata } from "@nestjs/common/interfaces"; + +export interface RabbitMqModuleOptions { + user?: string, + passwd?: string, + host?: string, + port?: number +} + +export interface RabbitMqModuleAsyncOptions extends Pick { + useFactory?: (...args: any[]) => RabbitMqModuleOptions | Promise, + inject?: any[]; +} \ No newline at end of file diff --git a/lib/rabbitmq.module.ts b/lib/rabbitmq.module.ts new file mode 100644 index 0000000..823b038 --- /dev/null +++ b/lib/rabbitmq.module.ts @@ -0,0 +1,36 @@ +import { Global, Module, DynamicModule } from '@nestjs/common' +import { RabbitMqModuleOptions, RabbitMqModuleAsyncOptions } from './rabbitmq.interface'; +import { RABBITMQ_MODULE_OPTIONS } from './rabbitmq.constants'; +import { RabbitMqService } from './rabbitmq.service'; +import { createClient,createAsyncClientOptions } from './rabbitmq-client.provider'; +@Global() +@Module({ + providers:[RabbitMqService], + exports: [RabbitMqService] +}) +export class RabbitMqModule { + static forRoot(options:RabbitMqModuleOptions) : DynamicModule { + return { + module: RabbitMqModule, + providers: [ + createClient(), + { + provide: RABBITMQ_MODULE_OPTIONS, + useValue: options + } + ], + exports: [RabbitMqService] + } + } + + static forRootSync(options: RabbitMqModuleAsyncOptions) : DynamicModule { + return { + module: RabbitMqModule, + providers: [ + createClient(), + createAsyncClientOptions(options), + ], + exports: [RabbitMqService] + } + } +} \ No newline at end of file diff --git a/lib/rabbitmq.service.ts b/lib/rabbitmq.service.ts new file mode 100644 index 0000000..08f587c --- /dev/null +++ b/lib/rabbitmq.service.ts @@ -0,0 +1,13 @@ +import { Injectable, Inject } from "@nestjs/common"; +import { RABBITMQ_CLIENT } from './rabbitmq.constants'; +import * as amqp from 'amqp-connection-manager' +@Injectable() +export class RabbitMqService { + constructor( + @Inject(RABBITMQ_CLIENT) private readonly client: amqp.AmqpConnectionManager + ) {} + + getClient(): amqp.AmqpConnectionManager { + return this.client + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..a6a537e --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "nestjs-rabbitmq", + "version": "1.0.0", + "description": "nest rabbitmq module", + "main": "index.js", + "author": "zzy", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/kyknow/nestjs-rabbitmq" + }, + "scripts": { + "build": "rm -rf dist && tsc -p tsconfig.json", + "precommit": "lint-staged", + "prepublish:npm": "yarn run build", + "publish:npm": "yarn publish --access public" + }, + "keywords": [ + "nestjs", + "nest", + "rabbitmq", + "amqp", + "amqplib", + "nestjs-rabbitmq" + ], + "dependencies": { + "@nestjs/common": "^5.4.1", + "amqp-connection-manager": "^2.3.0", + "amqplib": "^0.5.3" + }, + "devDependencies": { + "@types/amqp-connection-manager": "^2.0.1", + "@types/node": "^10.12.12", + "typescript": "^3.2.1" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ab66537 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "noImplicitAny": false, + "removeComments": true, + "noLib": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es6", + "sourceMap": false, + "outDir": "./dist", + "rootDir": "./lib", + "skipLibCheck": true + }, + "include": [ + "lib/**/*", + "../index.ts" + ], + "exclude": [ + "node_modules", + "**/*.spec.ts" + ] +} \ No newline at end of file diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000..3939be9 --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,7 @@ +{ + "extends": "tsconfig.json", + "compilerOptions": { + "types": ["jest", "node"] + }, + "include": ["**/*.spec.ts", "**/*.d.ts"] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..e66f0a4 --- /dev/null +++ b/tslint.json @@ -0,0 +1,55 @@ +{ + "defaultSeverity": "error", + "extends": [ + "tslint:recommended" + ], + "jsRules": { + "no-unused-expression": true + }, + "rules": { + "eofline": false, + "quotemark": [ + true, + "single" + ], + "indent": false, + "member-access": [ + false + ], + "ordered-imports": [ + false + ], + "max-line-length": [ + true, + 150 + ], + "member-ordering": [ + false + ], + "curly": false, + "interface-name": [ + false + ], + "array-type": [ + false + ], + "no-empty-interface": false, + "no-empty": false, + "arrow-parens": false, + "object-literal-sort-keys": false, + "no-unused-expression": false, + "max-classes-per-file": [ + false + ], + "variable-name": [ + false + ], + "one-line": [ + false + ], + "one-variable-per-declaration": [ + false + ] + }, + "rulesDirectory": [] +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..d2aff9f --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,34 @@ +const webpack = require('webpack'); +const path = require('path'); +const nodeExternals = require('webpack-node-externals'); + +module.exports = { + entry: ['webpack/hot/poll?1000', './src/main.hmr.ts'], + watch: true, + target: 'node', + externals: [ + nodeExternals({ + whitelist: ['webpack/hot/poll?1000'], + }), + ], + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + ], + }, + mode: "development", + resolve: { + extensions: ['.tsx', '.ts', '.js'], + }, + plugins: [ + new webpack.HotModuleReplacementPlugin(), + ], + output: { + path: path.join(__dirname, 'dist'), + filename: 'server.js', + }, +}; diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..d3dcc11 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,390 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@nestjs/common@^5.4.1": + version "5.4.1" + resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-5.4.1.tgz#7caef567c0aa116086c4785b48ce6df43194bc9d" + dependencies: + axios "0.18.0" + cli-color "1.2.0" + deprecate "1.0.0" + multer "1.3.0" + uuid "3.3.2" + +"@types/amqp-connection-manager@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@types/amqp-connection-manager/-/amqp-connection-manager-2.0.1.tgz#a367c1302df132eae1e9742ec4e62594607b9733" + dependencies: + "@types/amqplib" "*" + "@types/events" "*" + +"@types/amqplib@*": + version "0.5.9" + resolved "https://registry.yarnpkg.com/@types/amqplib/-/amqplib-0.5.9.tgz#94fa80fad2fdbe78f458ccb9c5fb0abfe62f817c" + dependencies: + "@types/bluebird" "*" + "@types/node" "*" + +"@types/bluebird@*": + version "3.5.24" + resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.24.tgz#11f76812531c14f793b8ecbf1de96f672905de8a" + +"@types/events@*": + version "1.2.0" + resolved "http://registry.npmjs.org/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" + +"@types/node@*", "@types/node@^10.12.12": + version "10.12.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.12.tgz#e15a9d034d9210f00320ef718a50c4a799417c47" + +amqp-connection-manager@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/amqp-connection-manager/-/amqp-connection-manager-2.3.0.tgz#bb6650479cb5df9952b365a8f55fa93e32d7edd6" + dependencies: + promise-breaker "^4.1.2" + +amqplib@^0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/amqplib/-/amqplib-0.5.3.tgz#7ccfc85d12ee7cd3c6dc861bb07f0648ec3d7193" + dependencies: + bitsyntax "~0.1.0" + bluebird "^3.5.2" + buffer-more-ints "~1.0.0" + readable-stream "1.x >=1.1.9" + safe-buffer "~5.1.2" + url-parse "~1.4.3" + +ansi-regex@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +append-field@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/append-field/-/append-field-0.1.0.tgz#6ddc58fa083c7bc545d3c5995b2830cc2366d44a" + +axios@0.18.0: + version "0.18.0" + resolved "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz#32d53e4851efdc0a11993b6cd000789d70c05102" + dependencies: + follow-redirects "^1.3.0" + is-buffer "^1.1.5" + +bitsyntax@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/bitsyntax/-/bitsyntax-0.1.0.tgz#b0c59acef03505de5a2ed62a2f763c56ae1d6205" + dependencies: + buffer-more-ints "~1.0.0" + debug "~2.6.9" + safe-buffer "~5.1.2" + +bluebird@^3.5.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + +buffer-more-ints@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-more-ints/-/buffer-more-ints-1.0.0.tgz#ef4f8e2dddbad429ed3828a9c55d44f05c611422" + +busboy@^0.2.11: + version "0.2.14" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-0.2.14.tgz#6c2a622efcf47c57bbbe1e2a9c37ad36c7925453" + dependencies: + dicer "0.2.5" + readable-stream "1.1.x" + +cli-color@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-1.2.0.tgz#3a5ae74fd76b6267af666e69e2afbbd01def34d1" + dependencies: + ansi-regex "^2.1.1" + d "1" + es5-ext "^0.10.12" + es6-iterator "2" + memoizee "^0.4.3" + timers-ext "0.1" + +concat-stream@^1.5.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +d@1: + version "1.0.0" + resolved "http://registry.npmjs.org/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + dependencies: + es5-ext "^0.10.9" + +debug@=3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + +debug@~2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +deprecate@1.0.0: + version "1.0.0" + resolved "http://registry.npmjs.org/deprecate/-/deprecate-1.0.0.tgz#661490ed2428916a6c8883d8834e5646f4e4a4a8" + +dicer@0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/dicer/-/dicer-0.2.5.tgz#5996c086bb33218c812c090bddc09cd12facb70f" + dependencies: + readable-stream "1.1.x" + streamsearch "0.1.2" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +es5-ext@^0.10.12, es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.45, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.46: + version "0.10.46" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.46.tgz#efd99f67c5a7ec789baa3daa7f79870388f7f572" + dependencies: + es6-iterator "~2.0.3" + es6-symbol "~3.1.1" + next-tick "1" + +es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-symbol@^3.1.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-weak-map@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + +event-emitter@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + +follow-redirects@^1.3.0: + version "1.5.10" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + dependencies: + debug "=3.1.0" + +inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + +is-promise@^2.1: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +lru-queue@0.1: + version "0.1.0" + resolved "https://registry.yarnpkg.com/lru-queue/-/lru-queue-0.1.0.tgz#2738bd9f0d3cf4f84490c5736c48699ac632cda3" + dependencies: + es5-ext "~0.10.2" + +media-typer@0.3.0: + version "0.3.0" + resolved "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +memoizee@^0.4.3: + version "0.4.14" + resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.14.tgz#07a00f204699f9a95c2d9e77218271c7cd610d57" + dependencies: + d "1" + es5-ext "^0.10.45" + es6-weak-map "^2.0.2" + event-emitter "^0.3.5" + is-promise "^2.1" + lru-queue "0.1" + next-tick "1" + timers-ext "^0.1.5" + +mime-db@~1.37.0: + version "1.37.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" + +mime-types@~2.1.18: + version "2.1.21" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96" + dependencies: + mime-db "~1.37.0" + +minimist@0.0.8: + version "0.0.8" + resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +mkdirp@^0.5.1: + version "0.5.1" + resolved "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +multer@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/multer/-/multer-1.3.0.tgz#092b2670f6846fa4914965efc8cf94c20fec6cd2" + dependencies: + append-field "^0.1.0" + busboy "^0.2.11" + concat-stream "^1.5.0" + mkdirp "^0.5.1" + object-assign "^3.0.0" + on-finished "^2.3.0" + type-is "^1.6.4" + xtend "^4.0.0" + +next-tick@1: + version "1.0.0" + resolved "http://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + +object-assign@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" + +on-finished@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + +promise-breaker@^4.1.2: + version "4.1.13" + resolved "https://registry.yarnpkg.com/promise-breaker/-/promise-breaker-4.1.13.tgz#fe57ad0a1f14912682942391de1e6a2b4e2e447b" + +querystringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.0.tgz#7ded8dfbf7879dcc60d0a644ac6754b283ad17ef" + +readable-stream@1.1.x, "readable-stream@1.x >=1.1.9": + version "1.1.14" + resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.2.2: + version "2.3.6" + resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + +safe-buffer@~5.1.0, safe-buffer@~5.1.1, safe-buffer@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + +streamsearch@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + dependencies: + safe-buffer "~5.1.0" + +timers-ext@0.1, timers-ext@^0.1.5: + version "0.1.7" + resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.7.tgz#6f57ad8578e07a3fb9f91d9387d65647555e25c6" + dependencies: + es5-ext "~0.10.46" + next-tick "1" + +type-is@^1.6.4: + version "1.6.16" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.18" + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +typescript@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.1.tgz#0b7a04b8cf3868188de914d9568bd030f0c56192" + +url-parse@~1.4.3: + version "1.4.4" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.4.tgz#cac1556e95faa0303691fec5cf9d5a1bc34648f8" + dependencies: + querystringify "^2.0.0" + requires-port "^1.0.0" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +uuid@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + +xtend@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"