Skip to content

Instantly share code, notes, and snippets.

View florianbepunkt's full-sized avatar

Florian Bischoff florianbepunkt

  • Berlin, Germany
View GitHub Profile
diff --git a/lib/packExternalModules.js b/lib/packExternalModules.js
index f45f6a6827e55c0363d005ed0a2d012cc60b3d46..0dd66e50edb29ca4861749cb65ece7fef51f1969 100644
--- a/lib/packExternalModules.js
+++ b/lib/packExternalModules.js
@@ -335,10 +335,13 @@ module.exports = {
// (1.a.1) Create a package.json
const compositePackage = _.defaults(
{
- name: this.serverless.service.service,
+ name: `${this.serverless.service.service}-dependencies`,
/**
/* An attempt to make the error handling process described on Khalil Stemmler's excellent
/* blog a little somewhat simpler.
/* https://khalilstemmler.com/articles/enterprise-typescript-nodejs/functional-error-handling/
/**
// Left and Right classes, but more specific to error handling.
class Failure<L, A = any> {
readonly error: L;
@florianbepunkt
florianbepunkt / mongodb-fle-lambda-race-condition-fix.js
Created September 1, 2020 13:20
MongoDB lambda mongocryptd race condition fix
// this is the writable folder where our .pid file live
const tmpPath = path.resolve(process.env.LAMBDA_TASK_ROOT, "../../tmp");
// if the file exists our ephemeral function container got reused, so we do not need to spawn the process again
if (!fs.existsSync(tmpPath + "/mongocryptd.pid")) {
await new Promise((resolve, reject) => {
// to prevent waiting for godot
const safeGuard = setTimeout(() => reject(), 3000);
const child = spawn(
const { Binary, MongoClient } = require("mongodb");
const path = require("path");
const connectionString =
"mongodb+srv://OMMITED.mongodb.net/yourDatabase?retryWrites=true&w=majority";
const keyVaultNamespace = "yourDatabase.__keyVault";
const base64KeyId = "OMITTED";
const createSchema = () => {
module.exports.hello = async (event) => {
process.env.PATH = `${process.env.PATH}:${process.env.LAMBDA_TASK_ROOT}/bin`;
const child = spawn("mongocryptd", [
"--idleShutdownTimeoutSecs=60",
]);
child.on("error", (error) => console.log(error));
child.stdout.on("data", (data) => {
autoEncryption: {
keyVaultNamespace,
kmsProviders,
schemaMap: createSchema(),
extraOptions: {
mongocryptdSpawnPath: `${process.env.LAMBDA_TASK_ROOT}/bin/mongocryptd`,
},
},
@florianbepunkt
florianbepunkt / mongo-fle-lambda-not-working.js
Created August 29, 2020 14:00
MongoDB Client-Side Field Level Encryption with Lambda - Not working example
const { Binary, MongoClient } = require("mongodb");
const path = require("path");
const connectionString =
"mongodb+srv://OMMITED.mongodb.net/yourDatabase?retryWrites=true&w=majority";
const keyVaultNamespace = "yourDatabase.__keyVault";
const base64KeyId = "OMITTED";
const createSchema = () => {
@florianbepunkt
florianbepunkt / index.ts
Created December 16, 2019 16:37
Flatten pdf with poppler utils pdftocairo
import { EventEmitter } from "events";
import { spawn, ChildProcess } from "child_process";
import { Writable } from "stream";
import fs from "fs";
/**
* from: https://github.com/rauschma/stringio/
*/
function streamPromiseHelper(
emitter: EventEmitter,
import React, { Component } from 'react';
import { StyleSheet, Text, ScrollView, View, Dimensions } from 'react-native';
import AutoResponisve from 'autoresponsive-react-native';
const SCREEN_WIDTH = Dimensions.get('window').width;
/**
* we store all of our elements calculated heights in there
* @type {Array}
*/