Skip to content

Instantly share code, notes, and snippets.

View mrtnzagustin's full-sized avatar

mrtnzagustin

View GitHub Profile
@mrtnzagustin
mrtnzagustin / spanish-joi-messages.json
Created April 21, 2020 16:41
Spanish messages to be used with @hapi/joi schema validation
{
"any.unknown": "no esta permitido",
"any.invalid": "contiene un valor invalido",
"any.empty": "no está permitido que sea vacío",
"any.required": "es requerido",
"any.allowOnly": "debería ser uno de las siguientes variantes: {{valids}}",
"any.default": "emitió un error cuando se ejecutó el metodo default",
"alternatives.base": "no coincide con ninguna de las alternativas permitidas",
"array.base": "debe ser un array",
"array.includes": "en la posición {{pos}} no coincide con ninguno de los tipos permitidos",
@mrtnzagustin
mrtnzagustin / index.d.ts
Created April 20, 2020 20:14 — forked from joeherold/index.d.ts
Sails Typings to work with Model, Controllers, ModelDefinition and so on...
// declare var ;
declare namespace Sails {
enum SortOption {
ASC,
DESC,
}
type SortOptions = keyof typeof SortOption;
interface Criteria {
or?: Criteria[];
@mrtnzagustin
mrtnzagustin / NativeQueryService.ts
Created April 20, 2020 20:14 — forked from joeherold/NativeQueryService.ts
A sample Service for Sails.js to transform a (in this case sails-postgres) raw result from sendNativeQuery to an regular model result
/*
* Created Date: Monday, April 20th 2020, 3:03:54 pm
* Author: Johannes Pichler
*
* Copyright (c) 2020 Webpixels e.U.
*/
let processAllRecords = require("waterline/lib/waterline/utils/query/process-all-records");
export type RawResult = {
@mrtnzagustin
mrtnzagustin / sailsBlueprintFind.js
Last active April 19, 2020 16:58
Custom find.js for Sails Models with record count based on limit or defaultLimit
function find (req, res) {
// Source: https://github.com/balderdashy/sails/tree/master/lib/hooks/blueprints/actions/find.js
var actionUtil = require('sails/lib/hooks/blueprints/actionUtil')
var formatUsageError = require('sails/lib/hooks/blueprints/formatUsageError')
var parseBlueprintOptions = req.options.parseBlueprintOptions || req._sails.config.blueprints.parseBlueprintOptions
// Set the blueprint action for parseBlueprintOptions.
req.options.blueprintAction = 'find'