Skip to content

Instantly share code, notes, and snippets.

View Frenchcooc's full-sized avatar
☄️
We're hiring 🤘

Corentin Frenchcooc

☄️
We're hiring 🤘
View GitHub Profile
@Frenchcooc
Frenchcooc / request-native.js
Created May 21, 2018 08:44
Make native http/https requests for node js
/*
* Make native http/https requests
*
* @usage: NativeRequest([URL|options])
* @demo: NativeRequest('https://example.org')
*
* @output: <http.ClientRequest> - see https://nodejs.org/api/http.html#http_http_request_options_callback
*/
const { URL } = require('url')
@Frenchcooc
Frenchcooc / regexp_capture.js
Last active May 21, 2018 16:28
Easy utilitary to get information from string using regexp
/**
* Simple RegExp capture
*/
function regexp_capture(regexp, data)
{
if (!data)
{ return false; }
var output = (new RegExp(regexp)).exec(data);
@Frenchcooc
Frenchcooc / List of the most common MIME types
Created July 19, 2018 13:13
Incomplete list of the most common MIME types
application/EDI-X12
application/EDIFACT
application/epub+zip
application/java-archive
application/javascript
application/json
application/ld+json
application/ms-word
application/msword
application/octet-stream
@Frenchcooc
Frenchcooc / eventlistener.js
Created December 2, 2018 18:31
Easy to use JS EventListener class
"use strict";
class EventListener {
constructor () {
// Declare variables
this._onEvents = [];
return this;
@Frenchcooc
Frenchcooc / oauth.js
Last active April 2, 2019 12:02
Fast expressjs app to retrieve OAuth tokens
/**
* Quick express-app to retrieve OAuth credentials
*
* Run it with $ node index.js
*/
const express = require('express')
const request = require('request')
const app = express()
@Frenchcooc
Frenchcooc / HTTPClients.md
Last active June 6, 2019 13:21
Different sdks
@Frenchcooc
Frenchcooc / SDK.md
Last active June 12, 2019 13:21
Collection of different SDK

Below is a collection of different SDK for the following APIs:

Stripe

Let's see how to post a message with a Slack bot, using Bearer.sh.

Steps

  1. Create a custom API on Bearer.sh dashboard (learn how here).
  2. Use the configuration below for that custom API
  3. Create a Slack bot on Slack (link)
  4. Register the Bot API Key on Bearer (it starts with xoxb-...)
  5. Post to a channel using the snippet below
@Frenchcooc
Frenchcooc / index.ts
Created January 17, 2020 16:09
Bearer Agent setup on Cloud Functions for Firebase
const Bearer = require('@bearer/node-agent')
Bearer.init({ secretKey: '...' })
import * as functions from 'firebase-functions'
import axios from 'axios'
export const test = functions.https.onRequest((request, response) => {
response.send('Hello from Firebase!')
})
// Require the library and client
const circuitBreaker = require("opossum")
const apiClient = require("our-example-api-client")
// Our example request
const getPosts = (req, res, next) => {
// Wrap our client get method in the circuit breaker
const breaker = circuitBreaker(apiClient.get, {
timeout: 3000,
errorThresholdPercentage: 50,
resetTimeout: 5000