提交 b7ee2022 authored 作者: zzy's avatar zzy

init

上级
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
\ No newline at end of file
{
"singleQuote": true,
"trailingComma": "all"
}
\ No newline at end of file
# Nest Redis Module
\ No newline at end of file
export * from './dist'
\ No newline at end of file
export * from './redis.service'
export * from './redis.module'
export * from './redis.interface'
\ No newline at end of file
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]
})
\ No newline at end of file
export const REDIS_MODULE_OPTIONS = Symbol('REDIS_MODULE_OPTIONS')
export const REDIS_CLIENT = Symbol('REDIS_CLIENT')
\ No newline at end of file
import { RedisOptions } from 'ioredis'
export interface RedisModuleOptions extends RedisOptions {}
\ No newline at end of file
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}
]
}
}
}
\ No newline at end of file
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
}
}
\ No newline at end of file
{
"language": "ts",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "node --inspect-brk -r ts-node/register src/main.ts"
}
\ No newline at end of file
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "ts-node -r tsconfig-paths/register src/main.ts"
}
{
"name": "nestjs-redis",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/ioredis": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.0.4.tgz",
"integrity": "sha512-QdJTMFrmKkphjoGIxItTMhP++8/6INLbgSIxB8kd9N+3OuiuiaZ2knt+OR4gFQrloac/ctwaQA1PCzISmD9afQ==",
"dev": true,
"requires": {
"@types/node": "10.12.12"
}
},
"@types/node": {
"version": "10.12.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.12.tgz",
"integrity": "sha512-Pr+6JRiKkfsFvmU/LK68oBRCQeEg36TyAbPhc2xpez24OOZZCuoIhWGTd39VZy6nGafSbxzGouFPTFD/rR1A0A==",
"dev": true
}
}
}
{
"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"
}
}
{
"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
{
"extends": "tsconfig.json",
"compilerOptions": {
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
{
"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": []
}
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',
},
};
此差异已折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论