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 { GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3"; | |
import stableStringify from "fast-json-stable-stringify"; | |
import forge from "node-forge"; | |
import { createS3Client } from "./client-aws"; | |
import { streamToString } from "./stream-ultils"; | |
function get128BitHash(input: string): string { | |
const messageDigest = forge.md.md5.create(); | |
messageDigest.update(input); | |
return messageDigest.digest().toHex(); |
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 pMap from "p-map"; | |
import { invokeLambdaAsync, invokeLambdaSync } from "./lambda-utils-aws"; | |
export const mapReduce = async <TItem, TMap, TReduce>(options: { | |
items: TItem[]; | |
map: { | |
functionName: string; | |
getPayloadForItem: (item: TItem) => TMap; | |
concurrency: number; | |
}; |
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
// Example usage of https://gist.github.com/vivmaha/f34fdea72d0f1fa0467a671b5ec7321e | |
render( | |
( | |
<BrowserRouter> | |
<div> | |
<ScrollToTop /> | |
<Route exact path="/" component={Home} /> | |
<Route path="/article/:id" component={Article} /> | |
<Route path="/series/:id" component={ArticleSet} /> |
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 * as React from "react"; | |
import { RouteComponentProps, withRouter } from "react-router"; | |
// Scroll restoration based on https://reacttraining.com/react-router/web/guides/scroll-restoration. | |
export var ScrollToTop = withRouter( | |
class ScrollToTopWithoutRouter extends React.Component<RouteComponentProps<any>, void> { | |
componentDidUpdate(prevProps: Readonly<RouteComponentProps<any>>) { | |
if (this.props.location !== prevProps.location) { | |
window.scrollTo(0, 0) | |
} |