forked from skunight/nestjs-redis
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7ee202
Showing
20 changed files
with
699 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
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 | ||
dist/ | ||
logs/ | ||
*.thrift | ||
*.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Nest Redis Module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './dist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './redis.service' | ||
export * from './redis.module' | ||
export * from './redis.interface' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as Redis from "ioredis" | ||
import { REDIS_CLIENT, REDIS_MODULE_OPTIONS } from './redis.constants'; | ||
import { RedisModuleOptions } from "./redis.interface"; | ||
|
||
export const createClient = () => ({ | ||
provide: REDIS_CLIENT, | ||
useFactory:(options: RedisModuleOptions) => { | ||
return new Redis(options) | ||
}, | ||
inject:[REDIS_MODULE_OPTIONS] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const REDIS_MODULE_OPTIONS = Symbol('REDIS_MODULE_OPTIONS') | ||
export const REDIS_CLIENT = Symbol('REDIS_CLIENT') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { RedisOptions } from 'ioredis' | ||
|
||
export interface RedisModuleOptions extends RedisOptions {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { DynamicModule, Module } from '@nestjs/common'; | ||
import { RedisModuleOptions } from './redis.interface'; | ||
import { REDIS_MODULE_OPTIONS } from './redis.constants'; | ||
import { RedisService } from './redis.service'; | ||
|
||
@Module({ | ||
providers:[RedisService], | ||
exports:[RedisService] | ||
}) | ||
export class RedisModule { | ||
static register(options:RedisModuleOptions): DynamicModule { | ||
return { | ||
module: RedisModule, | ||
providers: [ | ||
{ provide: REDIS_MODULE_OPTIONS,useValue:options} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Injectable, Inject } from "@nestjs/common"; | ||
import { REDIS_CLIENT } from './redis.constants'; | ||
import * as Redis from "ioredis"; | ||
|
||
@Injectable() | ||
export class RedisService { | ||
constructor( | ||
@Inject(REDIS_CLIENT) private readonly client: Redis.Redis | ||
) {} | ||
|
||
getClient() : Redis.Redis { | ||
return this.client | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"language": "ts", | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"watch": ["src"], | ||
"ext": "ts", | ||
"ignore": ["src/**/*.spec.ts"], | ||
"exec": "node --inspect-brk -r ts-node/register src/main.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"watch": ["src"], | ||
"ext": "ts", | ||
"ignore": ["src/**/*.spec.ts"], | ||
"exec": "ts-node -r tsconfig-paths/register src/main.ts" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "nestjs-redis", | ||
"version": "0.0.0", | ||
"description": "a nestjs redis module", | ||
"author": "zzy", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "rm -rf dist && tsc -p tsconfig.json", | ||
"precommit": "lint-staged", | ||
"prepublish:npm": "yarn run build", | ||
"publish:npm": "yarn publish --access public" | ||
}, | ||
"dependencies": { | ||
"@nestjs/common": "^5.1.0", | ||
"ioredis": "^4.2.0", | ||
"rxjs": "^6.2.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^10.7.1", | ||
"typescript": "^2.4.2", | ||
"@types/ioredis": "^4.0.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["**/*.spec.ts", "**/*.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}, | ||
}; |
Oops, something went wrong.