Skip to content

Commit

Permalink
Moved Maker API service into its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpetro committed Mar 3, 2024
1 parent e8c7794 commit 35bb982
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IrrigationEventsModule } from './irrigation-events/irrigation-events.mo
import { DevtoolsModule } from '@nestjs/devtools-integration'
import { SunriseSunsetModule } from './sunrise-sunset/sunrise-sunset.module'
import { IrrigationProgramsModule } from './irrigation-programs/irrigation-programs.module'
import { MakerApiModule } from './maker-api/maker-api.module'

@Module({
imports: [
Expand All @@ -14,6 +15,7 @@ import { IrrigationProgramsModule } from './irrigation-programs/irrigation-progr
IrrigationEventsModule,
SunriseSunsetModule,
IrrigationProgramsModule,
MakerApiModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/irrigation-events/dto/maker-api-event.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceState } from '../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { Equals, IsNumber, IsString, IsEnum } from 'class-validator'

export class MakerApiEventDto {
Expand Down
2 changes: 1 addition & 1 deletion src/irrigation-events/entities/irrigation-event.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IdentifiedDocument } from 'nano'
import { DeviceState } from '../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'

export class IrrigationEventDocument implements IdentifiedDocument {
_id: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceState } from '../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { IrrigationEvent } from './irrigation-event.interface'

export interface DeviceEvents {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceState } from '../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'

export interface IrrigationEvent {
timestamp: Date
Expand Down
6 changes: 3 additions & 3 deletions src/irrigation-events/irrigation-events.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Test, TestingModule } from '@nestjs/testing'
import { IrrigationEventsController } from '@/irrigation-events/irrigation-events.controller'
import { MakerApiService } from './maker-api.service'
import { MakerApiService } from '@/maker-api/maker-api.service'
import { ViewmodelTransformService } from './viewmodel-transform.service'
import { IrrigationEventsService } from './irrigation-events.service'
import { ConfigModule } from '@nestjs/config'
import { DeviceState } from './enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { MakerApiEventDto } from './dto/maker-api-event.dto'
import { IrrigationEvent } from './interfaces/irrigation-event.interface'
import { parseISO } from 'date-fns'
import { DeviceStates } from './interfaces/device-states.interface'
import { DeviceStates } from '@/maker-api/interfaces/device-states.interface'
import { IrrigationEventViewmodel } from './dto/irrigation-event-viewmodel.dto'

describe('IrrigationEventsController', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/irrigation-events/irrigation-events.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { isWithinInterval, parseISO } from 'date-fns'
import { IrrigationEventsService } from './irrigation-events.service'
import { IrrigationEvent } from './interfaces/irrigation-event.interface'
import { MakerApiEventDto } from './dto/maker-api-event.dto'
import { DeviceState } from './enums/device-state.interface'
import { MakerApiService } from './maker-api.service'
import { DeviceState } from '@/enums/device-state.interface'
import { MakerApiService } from '@/maker-api/maker-api.service'
import { ViewmodelTransformService } from './viewmodel-transform.service'
import { DeviceEvents } from './interfaces/device-events.interface'

Expand Down
6 changes: 3 additions & 3 deletions src/irrigation-events/irrigation-events.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Module } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { MakerApiModule } from '@/maker-api/maker-api.module'
import { IrrigationEventsService } from '@/irrigation-events/irrigation-events.service'
import { IrrigationEventsController } from '@/irrigation-events/irrigation-events.controller'
import { MakerApiService } from './maker-api.service'
import { ViewmodelTransformService } from './viewmodel-transform.service'
import { DatabaseModule } from '@/database/database.module'

@Module({
imports: [ConfigModule, DatabaseModule],
imports: [ConfigModule, DatabaseModule, MakerApiModule],
controllers: [IrrigationEventsController],
providers: [IrrigationEventsService, MakerApiService, ViewmodelTransformService],
providers: [IrrigationEventsService, ViewmodelTransformService],
})
export class IrrigationEventsModule {}
2 changes: 1 addition & 1 deletion src/irrigation-events/irrigation-events.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing'
import { IrrigationEvent } from './interfaces/irrigation-event.interface'
import { IrrigationEventDocument } from './entities/irrigation-event.entity'
import { MakerApiEventDto } from './dto/maker-api-event.dto'
import { DeviceState } from './enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { ConfigModule } from '@nestjs/config'
import { parseISO } from 'date-fns'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IrrigationEvent } from '../../interfaces/irrigation-event.interface'
import { DeviceState } from '../../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { DeviceEvents } from '../../interfaces/device-events.interface'
import { IrrigationEventViewmodel } from '../../dto/irrigation-event-viewmodel.dto'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IrrigationEvent } from '../../interfaces/irrigation-event.interface'
import { DeviceState } from '../../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { DeviceEvents } from '../../interfaces/device-events.interface'
import { IrrigationEventViewmodel } from '../../dto/irrigation-event-viewmodel.dto'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IrrigationEvent } from '../../interfaces/irrigation-event.interface'
import { DeviceState } from '../../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { Warning } from '../../enums/warning.interface'
import { DeviceEvents } from '../../interfaces/device-events.interface'
import { IrrigationEventViewmodel } from '../../dto/irrigation-event-viewmodel.dto'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IrrigationEvent } from '../../interfaces/irrigation-event.interface'
import { DeviceState } from '../../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { Warning } from '../../enums/warning.interface'
import { DeviceEvents } from '../../interfaces/device-events.interface'
import { IrrigationEventViewmodel } from '../../dto/irrigation-event-viewmodel.dto'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IrrigationEvent } from '../../interfaces/irrigation-event.interface'
import { DeviceState } from '../../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { Warning } from '../../enums/warning.interface'
import { DeviceEvents } from '../../interfaces/device-events.interface'
import { IrrigationEventViewmodel } from '../../dto/irrigation-event-viewmodel.dto'
Expand Down
2 changes: 1 addition & 1 deletion src/irrigation-events/viewmodel-transform.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common'
import { compareAsc, roundToNearestMinutes } from 'date-fns'
import { IrrigationEventViewmodel } from './dto/irrigation-event-viewmodel.dto'
import { DeviceState } from './enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'
import { Warning } from './enums/warning.interface'
import { DeviceEvents } from './interfaces/device-events.interface'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceState } from '../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'

export interface DeviceStates {
[deviceId: number]: DeviceState | undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceState } from '../enums/device-state.interface'
import { DeviceState } from '@/enums/device-state.interface'

export interface MakerDeviceDetails {
id: string
Expand Down
10 changes: 10 additions & 0 deletions src/maker-api/maker-api.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common'
import { MakerApiService } from './maker-api.service'
import { ConfigModule } from '@nestjs/config'

@Module({
imports: [ConfigModule],
providers: [MakerApiService],
exports: [MakerApiService],
})
export class MakerApiModule {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing'
import { MakerApiService } from '@/irrigation-events/maker-api.service'
import { MakerApiService } from './maker-api.service'
import { ConfigModule } from '@nestjs/config'
import mockData from './mocks/maker-api.mocks.json'
import axios from 'axios'
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 35bb982

Please sign in to comment.