- replaced validation library @adonisjs/validator with @vinejs/vine (performance)
Some checks failed
CI Pipeline / japa-tests (push) Failing after 56s
Some checks failed
CI Pipeline / japa-tests (push) Failing after 56s
- npm updates
This commit is contained in:
parent
08c2edca3b
commit
ec17d79cf2
32 changed files with 1677 additions and 1670 deletions
|
@ -8,7 +8,6 @@ import { XMLBuilder } from 'xmlbuilder2/lib/interfaces.js';
|
|||
import { create } from 'xmlbuilder2';
|
||||
import { readFileSync } from 'fs';
|
||||
import SaxonJS from 'saxon-js';
|
||||
import { schema } from '@adonisjs/validator';
|
||||
import { DateTime } from 'luxon';
|
||||
import Index from '#app/Library/Utils/Index';
|
||||
import { getDomain } from '#app/utils/utility-functions';
|
||||
|
@ -17,14 +16,14 @@ import DoiClientException from '#app/exceptions/DoiClientException';
|
|||
import logger from '@adonisjs/core/services/logger';
|
||||
import { HttpException } from 'node-exceptions';
|
||||
import { ModelQueryBuilderContract } from "@adonisjs/lucid/types/model";
|
||||
import { CustomMessages } from "@adonisjs/validator/types";
|
||||
import vine, { SimpleMessagesProvider } from '@vinejs/vine';
|
||||
|
||||
// Create a new instance of the client
|
||||
const client = new Client({ node: 'http://localhost:9200' }); // replace with your OpenSearch endpoint
|
||||
|
||||
export default class DatasetsController {
|
||||
private proc;
|
||||
public messages: CustomMessages = {
|
||||
public messages = {
|
||||
// 'required': '{{ field }} is required',
|
||||
// 'licenses.minLength': 'at least {{ options.minLength }} permission must be defined',
|
||||
'reviewer_id.required': 'reviewer_id must be defined',
|
||||
|
@ -184,11 +183,13 @@ export default class DatasetsController {
|
|||
}
|
||||
|
||||
public async approveUpdate({ request, response }: HttpContext) {
|
||||
const approveDatasetSchema = schema.create({
|
||||
reviewer_id: schema.number(),
|
||||
const approveDatasetSchema = vine.object({
|
||||
reviewer_id: vine.number(),
|
||||
});
|
||||
try {
|
||||
await request.validate({ schema: approveDatasetSchema, messages: this.messages });
|
||||
// await request.validate({ schema: approveDatasetSchema, messages: this.messages });
|
||||
const validator = vine.compile(approveDatasetSchema);
|
||||
await request.validateUsing(validator, { messagesProvider: new SimpleMessagesProvider(this.messages) });
|
||||
} catch (error) {
|
||||
// return response.badRequest(error.messages);
|
||||
throw error;
|
||||
|
@ -252,13 +253,14 @@ export default class DatasetsController {
|
|||
}
|
||||
|
||||
public async publishUpdate({ request, response }: HttpContext) {
|
||||
const publishDatasetSchema = schema.create({
|
||||
publisher_name: schema.string({ trim: true }),
|
||||
const publishDatasetSchema = vine.object({
|
||||
publisher_name: vine.string().alphaNumeric().trim(),
|
||||
});
|
||||
try {
|
||||
await request.validate({ schema: publishDatasetSchema, messages: this.messages });
|
||||
// await request.validate({ schema: publishDatasetSchema, messages: this.messages });
|
||||
const validator = vine.compile(publishDatasetSchema);
|
||||
await request.validateUsing(validator, { messagesProvider: new SimpleMessagesProvider(this.messages) });
|
||||
} catch (error) {
|
||||
// return response.badRequest(error.messages);
|
||||
throw error;
|
||||
}
|
||||
const id = request.param('id');
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue