Remove redundant comments and improve code formatting

This commit is contained in:
rafaeldpsilva
2025-09-23 15:24:04 +01:00
parent a3d266d735
commit 6510468768
5 changed files with 102 additions and 141 deletions

View File

@@ -1,8 +1,3 @@
/**
* API Service Layer for Energy Monitoring Dashboard
* Handles all backend API communications
*/
// Base configuration
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000'

View File

@@ -22,26 +22,17 @@ export interface TokenValidation {
}
export const authApi = {
/**
* Generate a new JWT token for the dashboard
*/
async generateToken(request: TokenRequest): Promise<TokenResponse> {
return apiClient.post<TokenResponse>('/api/v1/tokens/generate', request)
},
/**
* Validate an existing token
*/
async validateToken(token: string): Promise<TokenValidation> {
return apiClient.post<TokenValidation>('/api/v1/tokens/validate', { token })
},
/**
* Revoke a token
*/
async revokeToken(token: string): Promise<{ message: string }> {
return apiClient.post<{ message: string }>('/api/v1/tokens/revoke', { token })
}
},
}
export default authApi
export default authApi

View File

@@ -1,7 +1,3 @@
/**
* Sensors API Service
* Handles sensor-related API calls
*/
import {
apiClient,
type SensorInfo,
@@ -13,9 +9,6 @@ import {
} from './api'
export const sensorsApi = {
/**
* Get all sensors with optional filtering
*/
async getSensors(params?: {
room?: string
sensor_type?: SensorType
@@ -24,16 +17,10 @@ export const sensorsApi = {
return apiClient.get<SensorInfo[]>('/api/v1/sensors', params)
},
/**
* Get detailed information about a specific sensor
*/
async getSensor(sensorId: string): Promise<SensorInfo> {
return apiClient.get<SensorInfo>(`/api/v1/sensors/${sensorId}`)
},
/**
* Get historical data for a specific sensor
*/
async getSensorData(
sensorId: string,
params?: {
@@ -46,16 +33,10 @@ export const sensorsApi = {
return apiClient.get<DataResponse>(`/api/v1/sensors/${sensorId}/data`, params)
},
/**
* Advanced data query with multiple filters
*/
async queryData(query: DataQuery): Promise<DataResponse> {
return apiClient.post<DataResponse>('/api/v1/data/query', query)
},
/**
* Update sensor metadata
*/
async updateSensorMetadata(
sensorId: string,
metadata: Record<string, any>,
@@ -63,9 +44,6 @@ export const sensorsApi = {
return apiClient.put<{ message: string }>(`/api/v1/sensors/${sensorId}/metadata`, metadata)
},
/**
* Delete sensor and all its data
*/
async deleteSensor(sensorId: string): Promise<{
message: string
readings_deleted: number
@@ -74,9 +52,6 @@ export const sensorsApi = {
return apiClient.delete(`/api/v1/sensors/${sensorId}`)
},
/**
* Export sensor data for specified time range
*/
async exportData(params: {
start_time: number
end_time: number