Skip to content

Instantly share code, notes, and snippets.

View rossanthony's full-sized avatar

Ross Anthony rossanthony

  • Birkbeck, University of London
  • Detroit, USA
View GitHub Profile
@Roms1383
Roms1383 / validation.pipe.test.ts
Created March 27, 2020 17:09
Medium - Easy validation with Nest.js and Joi
import * as Joi from '@hapi/joi'
import { Body, Controller, Module, NotImplementedException, Post, UsePipes } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import axios from 'axios'
import * as Joiful from 'joiful'
import { ValidationPipe } from './validation.pipe'
class Implicit {
@Joiful.string().required()
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,

Understanding this in JavaScript

It's easy to trip up on the meaning of this in JavaScript. The behavior is very different from other languages, which means we have to throw most preconceptions and intuition out the window.

The best way to think of this in JS is as a hidden function argument which is passed in a slightly awkward way. Instead of the normal passing of arguments:

fn(arg1, arg2, arg3)