Skip to content

Instantly share code, notes, and snippets.

View israeleriston's full-sized avatar

Israel Ériston israeleriston

  • MGA Gestão Pública
  • Brasil
View GitHub Profile
@israeleriston
israeleriston / schema.js
Created May 17, 2018 03:52
Simple scheme using fastify
const schema = {
response: {
'2xx': {
type: 'object',
properties: {
value: { type: 'string' },
otherValue: { type: 'boolean' }
}
},
@israeleriston
israeleriston / route.js
Last active May 17, 2018 03:35
Simple example the using fastify with default response
'use strict'
const fastify = require('fastify')()
const handler = (req, reply) => {
reply.send({ hello: 'world' })
}
const route = {
method: 'GET',
@israeleriston
israeleriston / Route.js
Created May 5, 2018 18:10
Auto loading the routes
const middleware = require('./Middleware')
const create = handler => ({
name: 'user-create',
path: '/user',
version: '1.0.1',
method: 'post',
handler: () => handler
})
test('Inject GET request fastify', t => {
const fastify = Fastify()
const payload = {
hello: 'world'
}
fastify.get('/', (req, reply) => {
reply.send(payload)
})
@israeleriston
israeleriston / module.js
Last active April 26, 2018 04:07
Commits and Mutations examples vuex
import service from './service-http'
const SET_USER = 'user/SET_USER'
const state = {
user: ''
}
const actions = {
@israeleriston
israeleriston / state.js
Created April 26, 2018 01:00
Example of pattern State Manager
class Car {
constructor(count, currentState) {
this.count = 0
this.currentState = new Red(this)
}
change (state) {
if (this.count++ >= 10) {
return
}
@israeleriston
israeleriston / file.vue
Created April 17, 2018 03:33
footer vuejs componenter
<template>
<section class="footer-accordeon" :class="{ '-open': open }">
<header class="header" @click="open = !open">
<h4 class="title">{{ title }}</h4>
<batista-icon class="icon" icon="arrow_down" size="9" />
</header>
<div class="content" :style="contentStyle">
<slot />
</div>
</section>
@israeleriston
israeleriston / file.js
Created April 14, 2018 19:34
donwload imagens of storage firebase
const img = ['images/education/bauru/elementaryI/carousel02', 'images/education/bauru/elementaryI/carousel01' ]
// example should imagens path
this.grade.images.forEach((img) => {
this.$fireApp.storage().ref().child(img).getDownloadURL().then((url) => {
this.images.push(url)
})
})
@israeleriston
israeleriston / index.js
Created April 13, 2018 21:12
Function cloud send e-mail using firebase
var user = event.data.val()
var { age, email, grade, name, phone, text, unit } = user
const destination = unit === 'Perdizes' ? 'debora.bueno@batistabrasileiro.com.br' : 'secretariageral@cbbauru.com.br'
const to = project === 'batista-webapp' ? destination : 'contato@guibarscevicius.com.br'
console.log('projeto:', project)
var data = {
@israeleriston
israeleriston / http.js
Created March 19, 2018 17:47
Axios and Vuejs Integration
import axios from 'axios'
export const http = axios.create({
baseURL: process.env.SUA_API
})
export default function install (Vue) {
Object.defineProperty(Vue.prototype, '$http', {
get: () => http
})