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