This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const AWS = require('aws-sdk'); | |
const ssm = new AWS.SSM({ region: 'eu-central-1' }); | |
const SOURCE_COOKIE_NAME = 'myapp-origin'; | |
const LATEST_ORIGIN_GIT_HASH = 'myapp_latest-origin-git-hash'; | |
exports.handler = async event => { | |
console.group('[INFO] lambda@edge Origin Response') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const SOURCE_HEADER_NAME = 'x-myapp-origin'; | |
exports.handler = async event => { | |
console.group('[INFO] lambda@edge Origin Request') | |
const request = event.Records[0].cf.request; | |
if (request.headers[SOURCE_HEADER_NAME]) { | |
const headerValue = request.headers[SOURCE_HEADER_NAME][0].value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const AWS = require('aws-sdk'); | |
const ssm = new AWS.SSM({ region: 'eu-central-1' }); | |
const SOURCE_COOKIE_NAME = 'myapp-origin'; | |
const LATEST_ORIGIN_GIT_HASH = 'myapp_latest-origin-git-hash'; | |
exports.handler = async (event, context, callback) => { | |
console.group('[INFO] lambda@edge Viewer Request') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core' | |
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router' | |
import { Observable } from 'rxjs' | |
import { distance } from 'fastest-levenshtein' | |
import { paths } from '../paths' | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class Redirect404Guard implements CanActivate { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { distance } = require('fastest-levenshtein') | |
// Approach B - Using distance which gives us more control in conjunction with a MAX_DISTANCE value | |
const routes = { | |
paymentMethods: 'paymentmethods', | |
accountData: 'account-data', | |
profile: 'profile', | |
privacySettings: 'privacy-settings', | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { closest, distance } = require('fastest-levenshtein') | |
// Approach A - Using closest | |
const routes = { | |
paymentMethods: 'paymentmethods', | |
accountData: 'account-data', | |
privacy: 'privacy', | |
privacySettings: 'privacy-settings', | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Un-gzip them | |
gzip -d -r -S .pbf * | |
# Rename them (this also renames all non-pbf files) | |
find . -type f -exec mv '{}' '{}'.pbf \; | |
# As i said, it renames all files so we have to remove the suffix once more | |
mv metadata.json{.pbf,} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd data/ | |
sudo apt-get install -y python | |
git clone https://github.com/mapbox/mbutil.git | |
./mbutil/mb-util --image_format=pbf tiles.mbtiles tiles | |
cd ../tiles/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We need make in order for openmaptiles to work correctly | |
sudo apt-get install -y make | |
# get the openmaptiles tooling | |
git clone https://github.com/openmaptiles/openmaptiles.git | |
cd ./openmaptiles | |
# We've decided to only get the mapdata until zoom level 12. It's a good idea to check first which zoom levels you'll need. Eveything higher then 12 take a lot of time and space | |
sed -i "/MAX_ZOOM=/c\MAX_ZOOM=12" .env | |
# Prep openmaptiles and download the raw OSM data for europe |
NewerOlder