Skip to content

Instantly share code, notes, and snippets.

View pariola's full-sized avatar
💭
open.

Blessing Pariola pariola

💭
open.
View GitHub Profile
@pariola
pariola / cfes6|app|index.js
Last active January 28, 2018 05:42
Hello World Cloud Function in ES6+
import * as functions from "firebase-functions";
export let helloWorld = functions.https.onRequest((req, res) => {
let world = `from ES6 in Cloud Functions!`;
res.status(200).send(`Hello ${world}`); // Template literals
});
{
"name": "cfes6",
"version": "1.0.0",
"description": "Using ES6+ in Cloud Functions",
"main": "index.js",
"scripts": {
"prebuild": "node node_modules/rimraf/bin functions",
"build": "babel app --out-dir functions --copy-files --ignore app/node_modules",
"postbuild": "cd functions && npm i -s",
"deploy": "npm run build && firebase deploy"
@pariola
pariola / cfes6|app|package.json
Created January 28, 2018 05:47
Package file for function
{
"name": "functions",
"description": "Cloud Function",
"dependencies": {
"firebase-admin": "^5.6.0",
"firebase-functions": "^0.7.5"
}
}
#! /usr/bin/env node
console.log("Hello World");
{
"name": "hellocli",
"version": "0.0.1",
"description": "Hello World in a CLI",
"bin": {
"hello-cli": "hellocli.js"
},
"keywords": ["hello", "cli"],
"author": {
"name": "Blessing Pariola"
@pariola
pariola / hellocli|hellocli.js
Last active January 30, 2018 04:16
New HelloCLI js
#! /usr/bin/env node
const argv = require('yargs').argv;
// Parse command
if (argv._.length == 1) {
switch (argv._[0]) {
case 'greet':
greet(argv);
break;
@pariola
pariola / hellocli|package.json
Created January 30, 2018 04:12
New package.json
{
"name": "hellocli",
"version": "0.0.1",
"description": "Hello World in a CLI",
"bin": {
"hello-cli": "hellocli.js"
},
"keywords": [
"hello",
"cli"
@pariola
pariola / index.js
Created December 23, 2018 13:16
Using the middleware pattern in now.sh
const Chain = require("middleware-chain-js");
const bodyParser = require("body-parser");
const app = new Chain();
//* parses JSON content
app.use(bodyParser.json());
app.use(function(req, res) {
console.log(req.body);