import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' import PaginationService from 'App/Services/PaginationService' import { schema } from '@ioc:Adonis/Core/Validator' import OcrRecord from 'App/Models/OcrRecord' import Drive from '@ioc:Adonis/Core/Drive' export default class OcrRecordController { private paginationService = new PaginationService(OcrRecord) public async index({ request }: HttpContextContract) { const res = await this.paginationService.paginate(request.all()) for (let e of res) { if (e.img) { e.img = await Drive.getSignedUrl(new URL(e.img).pathname.replace(/^\//, '')) } } return res } public async store({ request, bouncer }: HttpContextContract) { // await bouncer.authorize('admin') await request.validate({ schema: schema.create({ deviceId: schema.string(), record: schema.string() }) }) return await OcrRecord.create(request.all()) } }