Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump NestJS version and swicth from yarn to npm #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
6 changes: 3 additions & 3 deletions dist/redis-client.provider.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as Redis from 'ioredis';
import { Redis } from 'ioredis';
import { Provider } from '@nestjs/common';
import { RedisModuleAsyncOptions, RedisModuleOptions } from './redis.interface';
export declare class RedisClientError extends Error {
}
export interface RedisClient {
defaultKey: string;
clients: Map<string, Redis.Redis>;
clients: Map<string, Redis>;
size: number;
}
export declare const createClient: () => Provider;
export declare const createAsyncClientOptions: (options: RedisModuleAsyncOptions) => {
provide: symbol;
useFactory: (...args: any[]) => RedisModuleOptions | Promise<RedisModuleOptions> | RedisModuleOptions[] | Promise<RedisModuleOptions[]>;
useFactory: (...args: any[]) => RedisModuleOptions | RedisModuleOptions[] | Promise<RedisModuleOptions> | Promise<RedisModuleOptions[]>;
inject: any[];
};
12 changes: 7 additions & 5 deletions dist/redis-client.provider.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAsyncClientOptions = exports.createClient = exports.RedisClientError = void 0;
const Redis = require("ioredis");
const ioredis_1 = require("ioredis");
const uuid_1 = require("uuid");
const redis_constants_1 = require("./redis.constants");
class RedisClientError extends Error {
}
exports.RedisClientError = RedisClientError;
async function getClient(options) {
const { onClientReady, url, ...opt } = options;
const client = url ? new Redis(url) : new Redis(opt);
const client = url ? new ioredis_1.Redis(url) : new ioredis_1.Redis(opt);
if (onClientReady) {
onClientReady(client);
}
return client;
}
exports.createClient = () => ({
const createClient = () => ({
provide: redis_constants_1.REDIS_CLIENT,
useFactory: async (options) => {
const clients = new Map();
let defaultKey = uuid_1.v4();
let defaultKey = (0, uuid_1.v4)();
if (Array.isArray(options)) {
await Promise.all(options.map(async (o) => {
const key = o.name || defaultKey;
Expand All @@ -43,8 +43,10 @@ exports.createClient = () => ({
},
inject: [redis_constants_1.REDIS_MODULE_OPTIONS],
});
exports.createAsyncClientOptions = (options) => ({
exports.createClient = createClient;
const createAsyncClientOptions = (options) => ({
provide: redis_constants_1.REDIS_MODULE_OPTIONS,
useFactory: options.useFactory,
inject: options.inject,
});
exports.createAsyncClientOptions = createAsyncClientOptions;
18 changes: 10 additions & 8 deletions dist/redis-core.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const redis_client_provider_1 = require("./redis-client.provider");
const redis_constants_1 = require("./redis.constants");
const redis_service_1 = require("./redis.service");
let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
options;
redisClient;
constructor(options, redisClient) {
this.options = options;
this.redisClient = redisClient;
Expand All @@ -27,7 +29,7 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
return {
module: RedisCoreModule_1,
providers: [
redis_client_provider_1.createClient(),
(0, redis_client_provider_1.createClient)(),
{ provide: redis_constants_1.REDIS_MODULE_OPTIONS, useValue: options },
],
exports: [redis_service_1.RedisService],
Expand All @@ -37,7 +39,7 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
return {
module: RedisCoreModule_1,
imports: options.imports,
providers: [redis_client_provider_1.createClient(), redis_client_provider_1.createAsyncClientOptions(options)],
providers: [(0, redis_client_provider_1.createClient)(), (0, redis_client_provider_1.createAsyncClientOptions)(options)],
exports: [redis_service_1.RedisService],
};
}
Expand All @@ -58,14 +60,14 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
}
}
};
RedisCoreModule = RedisCoreModule_1 = __decorate([
common_1.Global(),
common_1.Module({
exports.RedisCoreModule = RedisCoreModule;
exports.RedisCoreModule = RedisCoreModule = RedisCoreModule_1 = __decorate([
(0, common_1.Global)(),
(0, common_1.Module)({
providers: [redis_service_1.RedisService],
exports: [redis_service_1.RedisService],
}),
__param(0, common_1.Inject(redis_constants_1.REDIS_MODULE_OPTIONS)),
__param(1, common_1.Inject(redis_constants_1.REDIS_CLIENT)),
__param(0, (0, common_1.Inject)(redis_constants_1.REDIS_MODULE_OPTIONS)),
__param(1, (0, common_1.Inject)(redis_constants_1.REDIS_CLIENT)),
__metadata("design:paramtypes", [Object, Object])
], RedisCoreModule);
exports.RedisCoreModule = RedisCoreModule;
6 changes: 3 additions & 3 deletions dist/redis.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let RedisModule = RedisModule_1 = class RedisModule {
};
}
};
RedisModule = RedisModule_1 = __decorate([
common_1.Module({})
], RedisModule);
exports.RedisModule = RedisModule;
exports.RedisModule = RedisModule = RedisModule_1 = __decorate([
(0, common_1.Module)({})
], RedisModule);
9 changes: 5 additions & 4 deletions dist/redis.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const common_1 = require("@nestjs/common");
const redis_constants_1 = require("./redis.constants");
const redis_client_provider_1 = require("./redis-client.provider");
let RedisService = class RedisService {
redisClient;
constructor(redisClient) {
this.redisClient = redisClient;
}
Expand All @@ -33,9 +34,9 @@ let RedisService = class RedisService {
return this.redisClient.clients;
}
};
RedisService = __decorate([
common_1.Injectable(),
__param(0, common_1.Inject(redis_constants_1.REDIS_CLIENT)),
exports.RedisService = RedisService;
exports.RedisService = RedisService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)(redis_constants_1.REDIS_CLIENT)),
__metadata("design:paramtypes", [Object])
], RedisService);
exports.RedisService = RedisService;
8 changes: 4 additions & 4 deletions lib/redis-client.provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Redis from 'ioredis';
import { Redis } from 'ioredis';
import { v4 as uuidv4 } from 'uuid';
import { Provider } from '@nestjs/common';

Expand All @@ -8,11 +8,11 @@ import { RedisModuleAsyncOptions, RedisModuleOptions } from './redis.interface';
export class RedisClientError extends Error {}
export interface RedisClient {
defaultKey: string;
clients: Map<string, Redis.Redis>;
clients: Map<string, Redis>;
size: number;
}

async function getClient(options: RedisModuleOptions): Promise<Redis.Redis> {
async function getClient(options: RedisModuleOptions): Promise<Redis> {
const { onClientReady, url, ...opt } = options;
const client = url ? new Redis(url) : new Redis(opt);
if (onClientReady) {
Expand All @@ -24,7 +24,7 @@ async function getClient(options: RedisModuleOptions): Promise<Redis.Redis> {
export const createClient = (): Provider => ({
provide: REDIS_CLIENT,
useFactory: async (options: RedisModuleOptions | RedisModuleOptions[]): Promise<RedisClient> => {
const clients = new Map<string, Redis.Redis>();
const clients = new Map<string, Redis>();
let defaultKey = uuidv4();

if (Array.isArray(options)) {
Expand Down
Loading