Skip to content

Instantly share code, notes, and snippets.

Avatar

mrtnzagustin

View GitHub Profile
@mrtnzagustin
mrtnzagustin / spanish-joi-messages.json
Created Apr 21, 2020
Spanish messages to be used with @hapi/joi schema validation
View spanish-joi-messages.json
{
"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 Apr 20, 2020 — forked from joeherold/index.d.ts
Sails Typings to work with Model, Controllers, ModelDefinition and so on...
View index.d.ts
// declare var ;
declare namespace Sails {
enum SortOption {
ASC,
DESC,
}
type SortOptions = keyof typeof SortOption;
interface Criteria {
or?: Criteria[];
@mrtnzagustin
mrtnzagustin / NativeQueryService.ts
Created Apr 20, 2020 — 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
View NativeQueryService.ts
/*
* 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 Apr 19, 2020
Custom find.js for Sails Models with record count based on limit or defaultLimit
View sailsBlueprintFind.js
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'