Skip to content

Commit

Permalink
Merge pull request #5 from xodms1701/main
Browse files Browse the repository at this point in the history
weather 모듈 생성
  • Loading branch information
xodms1701 authored Sep 4, 2024
2 parents 5546850 + f793d3b commit 0d6b20c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { BatchModule } from './batch/batch.module';
import { ScheduleModule } from '@nestjs/schedule';
import { WeatherModule } from './weather/weather.module';

@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
ScheduleModule.forRoot(),
BatchModule,
WeatherModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
18 changes: 18 additions & 0 deletions src/weather/weather.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { WeatherController } from './weather.controller';

describe('WeatherController', () => {
let controller: WeatherController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [WeatherController],
}).compile();

controller = module.get<WeatherController>(WeatherController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
12 changes: 12 additions & 0 deletions src/weather/weather.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { WeatherService } from './weather.service';

@Controller('weather')
export class WeatherController {
constructor(private readonly weatherService: WeatherService) {}

@Get()
async getWeathers() {
return this.weatherService.getWeathers();
}
}
10 changes: 10 additions & 0 deletions src/weather/weather.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { WeatherService } from './weather.service';
import { WeatherController } from './weather.controller';
import { PrismaService } from '../prisma.service';

@Module({
providers: [WeatherService, PrismaService],
controllers: [WeatherController],
})
export class WeatherModule {}
18 changes: 18 additions & 0 deletions src/weather/weather.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { WeatherService } from './weather.service';

describe('WeatherService', () => {
let service: WeatherService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [WeatherService],
}).compile();

service = module.get<WeatherService>(WeatherService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
11 changes: 11 additions & 0 deletions src/weather/weather.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma.service';

@Injectable()
export class WeatherService {
constructor(private readonly prismaService: PrismaService) {}

async getWeathers() {
return this.prismaService.recent_weather.findMany();
}
}

0 comments on commit 0d6b20c

Please sign in to comment.