import { GET, POST, QRequestController, SECURE, } from '../../modules/RequestController' export default class SettingsController extends QRequestController { @GET async index() { const settings = await this.db.collection('settings').find().toArray() return settings } @GET async _param(paramName: string) { const settings = await this.db.collection('settings').findOne({ _id: paramName, }) if (settings) { return settings } else { throw new Error('error') } } @POST @SECURE() async update() { const collection = this.splittedURL[2] await this.db .collection('settings') .updateOne({ _id: collection }, { $set: this.body }) return this.answer(true) } }