Skip to content

Instantly share code, notes, and snippets.

View jwerre's full-sized avatar
🏠
Working from home

Jonah Werre jwerre

🏠
Working from home
View GitHub Profile
@jwerre
jwerre / serverless.yaml
Last active May 27, 2021 22:08
Lambda@Edge Origin Request Event Handler - deployment configuration
---
service: my-lambda-edge
provider:
name: aws
region: us-east-1 # Lambda@Edge need to be in us-east-1
stage: ${opt:stage, 'production'}
runtime: nodejs14.x
stackName: ${self:service}-${self:provider.stage}
@jwerre
jwerre / origin_request.js
Last active May 28, 2021 16:39
Lambda@Edge Origin Request Event Handler - www to non-www permanent redirect
'use strict';
// Since you may want to have other redirects in the handler this
// function will simplify it a bit.
function redirect (url) {
return Promise.resolve({
body: '',
status: '301',
statusDescription: 'Permanently moved',
headers: {
@jwerre
jwerre / origin-request-event.json
Last active May 27, 2021 22:09
Lambda@Edge Origin Request Event
{
"Records": [
{
"cf": {
"config": {
"distributionDomainName": "d111111abcdef8.cloudfront.net",
"distributionId": "EDFDVBD6EXAMPLE",
"eventType": "origin-request",
"requestId": "4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ=="
},
@jwerre
jwerre / js
Last active April 15, 2021 20:56
Mongoose Select Bug
#!/usr/bin/env node
const {inspect} = require('util');
const mongoose = require('mongoose');
const DB_NAME = 'selectTest';
const LANGUGAGES = [
{
name: 'Danish',
code: 'da',
extends: 'eslint:recommended'
env:
node: true
mocha: true
es6: true
parserOptions:
ecmaVersion: 8
sourceType: module
ecmaFeatures:
globalReturn: false
h1 You've just sent a Pug email template from URI
p this email was sent to
a(href="mailto:"+email)=email
if amazing
p You are amazing!
else
p You did it!
<h1> You've just sent an HTML template with Underscore</h1>
<p> This email was sent to <a href="mailto:<%= email %>">email</a> </p>
<% if (amazing) { %>
<p>You are amazing!</p>
<% } else { %>
<p>You did it!</p>
<% } %>
<h1> You've just sent an HTML template with Underscore</h1>
<p> This email was sent to <a href="mailto:<%= email %>">email</a> </p>
<% if (amazing) { %>
<p>You are amazing!</p>
<% } else { %>
<p>You did it!</p>
<% } %>
You've just sent a plain text email with Underscore
this email was sent to <%= email %>
<% if (amazing) { %>
You are amazing!
<% } else { %>
You did it!
<% } %>
<h1> You've just sent an HTML template with EJS</h1>
<p> This email was sent to <a href="mailto:<%= email %>"><%= email %></a> </p>
<% if (amazing) { %>
<p>You are amazing!</p>
<% } else { %>
<p>You did it!</p>
<% } %>