Compare commits

...

2 Commits

Author SHA1 Message Date
expressgy 60251ca955 优化注释 2 years ago
expressgy 87cb473ff5 加入Redis 2 years ago
  1. 9
      config/development.ts
  2. 9
      config/production.ts
  3. 2
      package.json
  4. 136
      pnpm-lock.yaml
  5. 7
      src/GDEVINTERCEPTOR/gdevinterceptor.module.ts
  6. 18
      src/GDEVINTERCEPTOR/gdevinterceptor.service.spec.ts
  7. 16
      src/Gexceptions/gexceptionsfilter.filter.ts
  8. 9
      src/Ginterceptor/gdevinterceptor.interceptor.ts
  9. 42
      src/Ginterceptor/gresponseinterceptor.interceptor.ts
  10. 0
      src/Gservice/GDATABASE/gdatabase.module.ts
  11. 2
      src/Gservice/GDATABASE/gdatabase.service.ts
  12. 0
      src/Gservice/GLOGGER/glogger.module.ts
  13. 2
      src/Gservice/GLOGGER/glogger.service.ts
  14. 8
      src/Gservice/GREDIS/gredis.module.ts
  15. 21
      src/Gservice/GREDIS/gredis.service.ts
  16. 0
      src/Gservice/GREDIS/testJson.js
  17. 10
      src/app.module.ts
  18. 24
      src/main.ts
  19. 7
      src/response-interceptor/response-interceptor.module.ts
  20. 18
      src/response-interceptor/response-interceptor.service.spec.ts
  21. 4
      src/response-interceptor/response-interceptor.service.ts
  22. 13
      src/starlight/dto/create-starlight.dto.ts
  23. 12
      src/starlight/starlight.controller.ts
  24. 1
      src/starlight/starlight.module.ts

@ -23,4 +23,13 @@ export default {
database: 'Starlight',
},
},
redis: {
starLight: {
host: 'localhost',
port: 6379,
username: 'default',
password: 'default',
dbNumber: 3,
},
},
};

@ -23,4 +23,13 @@ export default {
database: 'Starlight',
},
},
redis: {
starLight: {
host: 'localhost',
port: 6379,
username: 'default',
password: 'default',
dbNumber: 3,
},
},
};

@ -32,6 +32,8 @@
"class-validator": "^0.14.0",
"fastify-swagger": "^5.2.0",
"log4js": "^6.9.1",
"mysql2": "^3.2.0",
"redis": "^4.6.5",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0"
},

@ -27,7 +27,9 @@ specifiers:
fastify-swagger: ^5.2.0
jest: 29.3.1
log4js: ^6.9.1
mysql2: ^3.2.0
prettier: ^2.3.2
redis: ^4.6.5
reflect-metadata: ^0.1.13
rxjs: ^7.2.0
source-map-support: ^0.5.20
@ -51,6 +53,8 @@ dependencies:
class-validator: 0.14.0
fastify-swagger: 5.2.0
log4js: 6.9.1
mysql2: 3.2.0
redis: 4.6.5
reflect-metadata: 0.1.13
rxjs: 7.8.0
@ -1238,6 +1242,55 @@ packages:
transitivePeerDependencies:
- encoding
/@redis/bloom/1.2.0_@redis+client@1.5.6:
resolution: {integrity: sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==}
peerDependencies:
'@redis/client': ^1.0.0
dependencies:
'@redis/client': 1.5.6
dev: false
/@redis/client/1.5.6:
resolution: {integrity: sha512-dFD1S6je+A47Lj22jN/upVU2fj4huR7S9APd7/ziUXsIXDL+11GPYti4Suv5y8FuXaN+0ZG4JF+y1houEJ7ToA==}
engines: {node: '>=14'}
dependencies:
cluster-key-slot: 1.1.2
generic-pool: 3.9.0
yallist: 4.0.0
dev: false
/@redis/graph/1.1.0_@redis+client@1.5.6:
resolution: {integrity: sha512-16yZWngxyXPd+MJxeSr0dqh2AIOi8j9yXKcKCwVaKDbH3HTuETpDVPcLujhFYVPtYrngSco31BUcSa9TH31Gqg==}
peerDependencies:
'@redis/client': ^1.0.0
dependencies:
'@redis/client': 1.5.6
dev: false
/@redis/json/1.0.4_@redis+client@1.5.6:
resolution: {integrity: sha512-LUZE2Gdrhg0Rx7AN+cZkb1e6HjoSKaeeW8rYnt89Tly13GBI5eP4CwDVr+MY8BAYfCg4/N15OUrtLoona9uSgw==}
peerDependencies:
'@redis/client': ^1.0.0
dependencies:
'@redis/client': 1.5.6
dev: false
/@redis/search/1.1.2_@redis+client@1.5.6:
resolution: {integrity: sha512-/cMfstG/fOh/SsE+4/BQGeuH/JJloeWuH+qJzM8dbxuWvdWibWAOAHHCZTMPhV3xIlH4/cUEIA8OV5QnYpaVoA==}
peerDependencies:
'@redis/client': ^1.0.0
dependencies:
'@redis/client': 1.5.6
dev: false
/@redis/time-series/1.0.4_@redis+client@1.5.6:
resolution: {integrity: sha512-ThUIgo2U/g7cCuZavucQTQzA9g9JbDDY2f64u3AbAoz/8vE2lt2U37LamDUVChhaDA3IRT9R6VvJwqnUfTJzng==}
peerDependencies:
'@redis/client': ^1.0.0
dependencies:
'@redis/client': 1.5.6
dev: false
/@sinclair/typebox/0.25.24:
resolution: {integrity: sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==}
dev: true
@ -2150,6 +2203,11 @@ packages:
engines: {node: '>=0.8'}
dev: true
/cluster-key-slot/1.1.2:
resolution: {integrity: sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==}
engines: {node: '>=0.10.0'}
dev: false
/co/4.6.0:
resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==}
engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'}
@ -2311,6 +2369,11 @@ packages:
engines: {node: '>=0.4.0'}
dev: true
/denque/2.1.0:
resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==}
engines: {node: '>=0.10'}
dev: false
/depd/1.1.2:
resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==}
engines: {node: '>= 0.6'}
@ -2976,6 +3039,17 @@ packages:
resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
dev: true
/generate-function/2.3.1:
resolution: {integrity: sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==}
dependencies:
is-property: 1.0.2
dev: false
/generic-pool/3.9.0:
resolution: {integrity: sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==}
engines: {node: '>= 4'}
dev: false
/gensync/1.0.0-beta.2:
resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==}
engines: {node: '>=6.9.0'}
@ -3149,6 +3223,13 @@ packages:
safer-buffer: 2.1.2
dev: true
/iconv-lite/0.6.3:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
dependencies:
safer-buffer: 2.1.2
dev: false
/ieee754/1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@ -3292,6 +3373,10 @@ packages:
engines: {node: '>=8'}
dev: true
/is-property/1.0.2:
resolution: {integrity: sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==}
dev: false
/is-stream/2.0.1:
resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==}
engines: {node: '>=8'}
@ -3937,6 +4022,10 @@ packages:
- supports-color
dev: false
/long/5.2.1:
resolution: {integrity: sha512-GKSNGeNAtw8IryjjkhZxuKB3JzlcLTwjtiQCHKvqQet81I93kXslhDQruGI/QsddO83mcDToBVy7GqGS/zYf/A==}
dev: false
/lru-cache/5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
dependencies:
@ -3949,6 +4038,11 @@ packages:
dependencies:
yallist: 4.0.0
/lru-cache/7.18.3:
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
engines: {node: '>=12'}
dev: false
/macos-release/2.5.1:
resolution: {integrity: sha512-DXqXhEM7gW59OjZO8NIjBCz9AQ1BEMrfiOAl4AYByHCtVHRF4KoGNO8mqQeM8lRCtQe/UnJ4imO/d2HdkKsd+A==}
engines: {node: '>=6'}
@ -4086,6 +4180,27 @@ packages:
resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==}
dev: true
/mysql2/3.2.0:
resolution: {integrity: sha512-0Vn6a9WSrq6fWwvPgrvIwnOCldiEcgbzapVRDAtDZ4cMTxN7pnGqCTx8EG32S/NYXl6AXkdO+9hV1tSIi/LigA==}
engines: {node: '>= 8.0'}
dependencies:
denque: 2.1.0
generate-function: 2.3.1
iconv-lite: 0.6.3
long: 5.2.1
lru-cache: 7.18.3
named-placeholders: 1.1.3
seq-queue: 0.0.5
sqlstring: 2.3.3
dev: false
/named-placeholders/1.1.3:
resolution: {integrity: sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w==}
engines: {node: '>=12.0.0'}
dependencies:
lru-cache: 7.18.3
dev: false
/natural-compare-lite/1.4.0:
resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==}
dev: true
@ -4485,6 +4600,17 @@ packages:
resolve: 1.22.1
dev: true
/redis/4.6.5:
resolution: {integrity: sha512-O0OWA36gDQbswOdUuAhRL6mTZpHFN525HlgZgDaVNgCJIAZR3ya06NTESb0R+TUZ+BFaDpz6NnnVvoMx9meUFg==}
dependencies:
'@redis/bloom': 1.2.0_@redis+client@1.5.6
'@redis/client': 1.5.6
'@redis/graph': 1.1.0_@redis+client@1.5.6
'@redis/json': 1.0.4_@redis+client@1.5.6
'@redis/search': 1.1.2_@redis+client@1.5.6
'@redis/time-series': 1.0.4_@redis+client@1.5.6
dev: false
/reflect-metadata/0.1.13:
resolution: {integrity: sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==}
@ -4607,7 +4733,6 @@ packages:
/safer-buffer/2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
dev: true
/schema-utils/3.1.1:
resolution: {integrity: sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==}
@ -4655,6 +4780,10 @@ packages:
- supports-color
dev: false
/seq-queue/0.0.5:
resolution: {integrity: sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q==}
dev: false
/serialize-javascript/6.0.1:
resolution: {integrity: sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==}
dependencies:
@ -4756,6 +4885,11 @@ packages:
resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==}
dev: true
/sqlstring/2.3.3:
resolution: {integrity: sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==}
engines: {node: '>= 0.6'}
dev: false
/stack-utils/2.0.6:
resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==}
engines: {node: '>=10'}

@ -1,7 +0,0 @@
import { Module } from '@nestjs/common';
import { GdevinterceptorService } from './gdevinterceptor.service';
@Module({
providers: [GdevinterceptorService]
})
export class GdevinterceptorModule {}

@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GdevinterceptorService } from './gdevinterceptor.service';
describe('GdevinterceptorService', () => {
let service: GdevinterceptorService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [GdevinterceptorService],
}).compile();
service = module.get<GdevinterceptorService>(GdevinterceptorService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

@ -0,0 +1,16 @@
import {
ArgumentsHost,
Catch,
ExceptionFilter,
HttpException,
} from '@nestjs/common';
@Catch()
export class GexceptionsfilterFilter<T> implements ExceptionFilter {
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const request = ctx.getRequest<Request>();
const status = exception.getStatus();
}
}

@ -1,14 +1,15 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
ExecutionContext,
CallHandler,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { GloggerService } from '../Gservice/GLOGGER/glogger.service';
import { tap } from 'rxjs/operators';
import { GloggerService } from '../GLOGGER/glogger.service';
@Injectable()
export class GdevinterceptorService implements NestInterceptor {
export class GdevinterceptorInterceptor implements NestInterceptor {
logger: GloggerService;
constructor() {
this.logger = new GloggerService();

@ -0,0 +1,42 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { GloggerService } from '../Gservice/GLOGGER/glogger.service';
import { map } from 'rxjs/operators';
@Injectable()
export class GresponseinterceptorInterceptor implements NestInterceptor {
logger: GloggerService;
constructor() {
this.logger = new GloggerService();
this.logger.setContext(`[Responseinterceptor]`);
}
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
const response = context.switchToHttp().getResponse();
return next.handle().pipe(
map((data) => {
// this.logger.debug(response.statusCode);
return JSON.stringify({
data:
typeof data == 'string'
? data
: data.data
? data.data
: data,
statusCode: response.statusCode,
success: true,
message:
typeof data == 'string'
? 'ok'
: data.message
? data.message
: 'ok',
});
}),
);
}
}

@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import * as mysql from 'mysql2/promise';
import config from '../../config';
import config from '../../../config';
@Injectable()
export class GdatabaseService {

@ -1,6 +1,6 @@
import { ConsoleLogger, Injectable, Scope } from '@nestjs/common';
import { configure, getLogger, Logger as log4jsLogger } from 'log4js';
import config from '../../config';
import config from '../../../config';
@Injectable({ scope: Scope.TRANSIENT })
export class GloggerService extends ConsoleLogger {

@ -0,0 +1,8 @@
import { Global, Module } from '@nestjs/common';
import { GredisService } from './gredis.service';
@Global()
@Module({
providers: [GredisService],
exports: [GredisService],
})
export class GredisModule {}

@ -0,0 +1,21 @@
import { Injectable } from '@nestjs/common';
import { createClient } from 'redis';
import config from '../../../config';
@Injectable()
export class GredisService {
public DB;
private config;
constructor() {
this.config = config().redis.starLight;
this.start();
}
private async start() {
const client = createClient({
url: `redis://${this.config.username}:${this.config.password}@${this.config.host}:${this.config.port}/${this.config.dbNumber}`,
});
await client.connect();
this.DB = client;
}
}

@ -1,11 +1,10 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { GloggerModule } from './GLOGGER/glogger.module';
import { StarlightModule } from './starlight/starlight.module';
import { GredisModule } from './Gservice/GREDIS/gredis.module';
import { GloggerModule } from './Gservice/GLOGGER/glogger.module';
import { GdatabaseModule } from './Gservice/GDATABASE/gdatabase.module';
import config from '../config';
import { GloggerService } from './GLOGGER/glogger.service';
import { GdatabaseModule } from './GDATABASE/gdatabase.module';
import { GdatabaseService } from './GDATABASE/gdatabase.service';
import { StarlightModule } from './starlight/starlight.module';
@Module({
imports: [
@ -16,6 +15,7 @@ import { GdatabaseService } from './GDATABASE/gdatabase.service';
GloggerModule,
StarlightModule,
GdatabaseModule,
GredisModule,
],
controllers: [],
providers: [],

@ -4,13 +4,23 @@ import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
// 参数验证
import { ValidationPipe } from '@nestjs/common';
// Fastify文件上传插件
import fastifyMultipart from '@fastify/multipart';
import { GloggerService } from './GLOGGER/glogger.service';
// 日志服务
import { GloggerService } from './Gservice/GLOGGER/glogger.service';
// API文档
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import * as process from 'process';
import { GdevinterceptorService } from './GDEVINTERCEPTOR/gdevinterceptor.service';
// 配置文件
import { ConfigService } from '@nestjs/config';
// 异常捕获
import { GexceptionsfilterFilter } from './Gexceptions/gexceptionsfilter.filter';
// 拦截器
// --全局开发拦截
import { GdevinterceptorInterceptor } from './Ginterceptor/gdevinterceptor.interceptor';
// --全局响应拦截
import { GresponseinterceptorInterceptor } from './Ginterceptor/gresponseinterceptor.interceptor';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
@ -39,6 +49,12 @@ async function bootstrap() {
const devInterceptorState = appConfig.get('dev').devInterceptor;
DevInterceptor(app, devInterceptorState, logger);
//全局响应拦截器
app.useGlobalInterceptors(new GresponseinterceptorInterceptor());
// 全局异常捕获
app.useGlobalFilters(new GexceptionsfilterFilter());
// 从配置文件的信息中启动服务
const listenConfig = appConfig.get('master');
await app.listen(listenConfig.port, listenConfig.host);
@ -65,7 +81,7 @@ function Swagger(app, state, logger) {
function DevInterceptor(app, state, logger) {
// 全局拦截器
if (!state) return;
app.useGlobalInterceptors(new GdevinterceptorService());
app.useGlobalInterceptors(new GdevinterceptorInterceptor());
logger.warn('DevInterceptorService请求响应拦截器已开启!');
}

@ -1,7 +0,0 @@
import { Module } from '@nestjs/common';
import { ResponseInterceptorService } from './response-interceptor.service';
@Module({
providers: [ResponseInterceptorService]
})
export class ResponseInterceptorModule {}

@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ResponseInterceptorService } from './response-interceptor.service';
describe('ResponseInterceptorService', () => {
let service: ResponseInterceptorService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ResponseInterceptorService],
}).compile();
service = module.get<ResponseInterceptorService>(ResponseInterceptorService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

@ -1,4 +0,0 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class ResponseInterceptorService {}

@ -1 +1,12 @@
export class CreateStarlightDto {}
import { IsNotEmpty, IsNumber, IsString } from 'class-validator';
export class CreateStarlightDto {
@IsNotEmpty({
message: 'name 不能为空',
})
@IsString()
name: string;
@IsNumber()
age: number;
}

@ -18,8 +18,9 @@ import { StarlightService } from './starlight.service';
import { CreateStarlightDto } from './dto/create-starlight.dto';
import { UpdateStarlightDto } from './dto/update-starlight.dto';
import { GloggerService } from '../GLOGGER/glogger.service';
import { GdatabaseService } from '../GDATABASE/gdatabase.service';
import { GloggerService } from '../Gservice/GLOGGER/glogger.service';
import { GdatabaseService } from '../Gservice/GDATABASE/gdatabase.service';
import { GredisService } from '../Gservice/GREDIS/gredis.service';
@ApiTags('starlight')
@Controller('starlight')
@ -31,10 +32,16 @@ export class StarlightController {
private readonly starlightService: StarlightService,
private readonly logger: GloggerService,
private readonly database: GdatabaseService,
private readonly redis: GredisService,
) {}
@Post()
create(@Body() createStarlightDto: CreateStarlightDto) {
this.logger.debug(createStarlightDto);
return {
name: createStarlightDto.name,
age: createStarlightDto.age,
};
return this.starlightService.create(createStarlightDto);
}
@ -46,6 +53,7 @@ export class StarlightController {
`SELECT * from user_info_base;`,
);
this.logger.debug(rows);
this.logger.debug(await this.redis.DB.json.get('JSON'));
return this.starlightService.findAll();
}

@ -1,7 +1,6 @@
import { Module } from '@nestjs/common';
import { StarlightService } from './starlight.service';
import { StarlightController } from './starlight.controller';
// import { LoggerService } from '../Logger/logger.service';
@Module({
controllers: [StarlightController],

Loading…
Cancel
Save