Commit 793b3245 authored by nanahira's avatar nanahira

add /api/ad

parent 6ecf5553
Pipeline #17951 passed with stages
in 5 minutes and 1 second
...@@ -7,4 +7,5 @@ DB_NAME: wall ...@@ -7,4 +7,5 @@ DB_NAME: wall
INITIAL_TIME: '2021-12-01 00:00:00' INITIAL_TIME: '2021-12-01 00:00:00'
FETCHER_URL: http://wenyuanwall-fetcher:3000 FETCHER_URL: http://wenyuanwall-fetcher:3000
CRON: '0 0 1 * * *' CRON: '0 0 1 * * *'
AD: ''
# http: # http:
import { Test, TestingModule } from '@nestjs/testing';
import { AdController } from './ad.controller';
describe('AdController', () => {
let controller: AdController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [AdController],
}).compile();
controller = module.get<AdController>(AdController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
import { Controller, Get } from '@nestjs/common';
import { AdService } from './ad.service';
import { ApiOkResponse, ApiOperation } from '@nestjs/swagger';
import { StringReturnMessageDto } from 'nicot';
@Controller('ad')
export class AdController {
constructor(private ad: AdService) {}
@Get()
@ApiOperation({ summary: 'Get ad' })
@ApiOkResponse({ type: StringReturnMessageDto })
getAd() {
return new StringReturnMessageDto(200, 'success', this.ad.getAd());
}
}
import { Test, TestingModule } from '@nestjs/testing';
import { AdService } from './ad.service';
describe('AdService', () => {
let service: AdService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AdService],
}).compile();
service = module.get<AdService>(AdService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class AdService {
constructor(private config: ConfigService) {}
getAd() {
return this.config.get<string>('AD', '');
}
}
...@@ -9,6 +9,8 @@ import { BlacklistAccountController } from './blacklist-account/blacklist-accoun ...@@ -9,6 +9,8 @@ import { BlacklistAccountController } from './blacklist-account/blacklist-accoun
import { BlacklistService } from './blacklist/blacklist.service'; import { BlacklistService } from './blacklist/blacklist.service';
import { FetchService } from './fetch/fetch.service'; import { FetchService } from './fetch/fetch.service';
import { HttpModule } from '@nestjs/axios'; import { HttpModule } from '@nestjs/axios';
import { AdService } from './ad/ad.service';
import { AdController } from './ad/ad.controller';
@Module({ @Module({
imports: [ imports: [
...@@ -40,7 +42,7 @@ import { HttpModule } from '@nestjs/axios'; ...@@ -40,7 +42,7 @@ import { HttpModule } from '@nestjs/axios';
}), }),
}), }),
], ],
providers: [BlacklistAccountService, BlacklistService, FetchService], providers: [BlacklistAccountService, BlacklistService, FetchService, AdService],
controllers: [BlacklistAccountController], controllers: [BlacklistAccountController, AdController],
}) })
export class AppModule {} export class AppModule {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment