mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
Remove useless method
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
||||
import Redis from "@ioc:Adonis/Addons/Redis";
|
||||
import StateSleepingValidator from "App/Validators/states/StateSleepingValidator";
|
||||
import StateDevelopingValidator from "App/Validators/states/StateDevelopingValidator";
|
||||
|
||||
export default class StatesController {
|
||||
|
||||
// Listening Music
|
||||
|
||||
public async index ({ response }: HttpContextContract) {
|
||||
const sleeping = this.formatValue(Boolean(await Redis.get('states:sleeping')) || false)
|
||||
const developing = this.formatValue(Boolean(await Redis.get('states:developing')) || false)
|
||||
const sleeping = this.formatValue(await Redis.get('states:sleeping'))
|
||||
const developing = this.formatValue(await Redis.get('states:developing'))
|
||||
return response.status(200).send({
|
||||
sleeping,
|
||||
developing,
|
||||
@@ -22,21 +21,12 @@ export default class StatesController {
|
||||
await Redis.set('states:sleeping', String(value))
|
||||
return response.status(200).send({
|
||||
message: 'State was successfully set!',
|
||||
value: this.formatValue(value)
|
||||
value: this.formatValue(String(value))
|
||||
})
|
||||
}
|
||||
|
||||
public async setDeveloping ({ request, response }: HttpContextContract) {
|
||||
const { value } = await request.validate(StateDevelopingValidator)
|
||||
await Redis.set('states:developing', String(value))
|
||||
return response.status(200).send({
|
||||
message: 'State was successfully set!',
|
||||
value: this.formatValue(value)
|
||||
})
|
||||
}
|
||||
|
||||
public formatValue (value: boolean): string {
|
||||
return value ? 'Yes' : 'No'
|
||||
public formatValue(value: string | null): string {
|
||||
return value === 'true' ? 'Yes' : 'No'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user