-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
117 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export type ActionMode = 'OUTPUT' | 'INPUT'; | ||
export type ActionValue = 'LOW' | 'HIGH'; | ||
export type ActionPin = string | number; | ||
|
||
export type OpenAction = { | ||
type: 'OPEN'; | ||
pin: ActionPin; | ||
mode: ActionMode; | ||
value: ActionValue; | ||
}; | ||
|
||
export type WriteAction = { | ||
type: 'WRITE'; | ||
pin: ActionPin; | ||
value: ActionValue; | ||
}; | ||
|
||
export type SleepAction = { | ||
type: 'SLEEP'; | ||
time: number; | ||
}; | ||
|
||
export type Action = OpenAction | WriteAction | SleepAction; | ||
|
||
export type ActionConfig = { | ||
onInit: Array<Action>; | ||
onToggle: Array<Action>; | ||
pinDefinition: Record<string, number>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/api/src/modules/configuration/config/configuration-config.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { ConfigModule } from '../../config/config.module'; | ||
import { ConfigurationConfigService } from './configuration-config.service'; | ||
|
||
@Module({ | ||
imports: [ConfigModule], | ||
providers: [ConfigurationConfigService], | ||
exports: [ConfigurationConfigService], | ||
}) | ||
export class ConfigurationConfigModule {} |
12 changes: 12 additions & 0 deletions
12
packages/api/src/modules/configuration/config/configuration-config.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
import { Config } from '../../config/config'; | ||
|
||
@Injectable() | ||
export class ConfigurationConfigService { | ||
constructor(private readonly config: Config) {} | ||
|
||
getDeviceTicket() { | ||
return this.config.device.ticket; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/api/src/modules/database/entities/config.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm'; | ||
|
||
@Entity('config') | ||
export class ConfigEntity { | ||
@PrimaryGeneratedColumn() | ||
public id: string; | ||
|
||
@CreateDateColumn({ | ||
type: 'timestamp', | ||
}) | ||
public createdAt: number; | ||
|
||
@CreateDateColumn({ | ||
type: 'timestamp', | ||
}) | ||
public updatedAt: number; | ||
|
||
@Column({ | ||
type: 'varchar', | ||
}) | ||
public value: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import { ConfigEntity } from './config.entity'; | ||
import { InvitationEntity } from './invitation.entity'; | ||
import { PushNotificationEntity } from './pushNotification.entity'; | ||
import { RefreshTokenEntity } from './refreshToken.entity'; | ||
import { UserEntity } from './user.entity'; | ||
|
||
export default [UserEntity, RefreshTokenEntity, InvitationEntity, PushNotificationEntity]; | ||
export default [ | ||
UserEntity, | ||
RefreshTokenEntity, | ||
InvitationEntity, | ||
PushNotificationEntity, | ||
ConfigEntity, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import constants from '../../utils/constants'; | ||
import { ConfigEntity } from '../database/entities/config.entity'; | ||
import { BaseRepository } from './base.repository'; | ||
|
||
export class ConfigRepository extends BaseRepository(ConfigEntity) { | ||
async getRaspberryPiActionConfig(): Promise<ConfigEntity | undefined> { | ||
const { | ||
DB_CONFIG_KEYS: { DEVICE_ACTION_CONFIG }, | ||
} = constants; | ||
return this.findOne({ where: { id: DEVICE_ACTION_CONFIG } }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ConfigRepository } from './config.repository'; | ||
import { InvitationRepository } from './invitation.repository'; | ||
import { PushNotificationRepository } from './push-notification.repository'; | ||
import { RefreshTokenRepository } from './refresh-token.repository'; | ||
import { UserRepository } from './user.repository'; | ||
|
||
export default [ | ||
UserRepository, | ||
InvitationRepository, | ||
RefreshTokenRepository, | ||
PushNotificationRepository, | ||
ConfigRepository, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters