This file contains hidden or 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 { DsqlSigner } from "@aws-sdk/dsql-signer" | |
import { drizzle } from "drizzle-orm/node-postgres" | |
import pg from "pg" | |
const { Client } = pg | |
const id = "<your-database-id>" as const | |
const endpoint = `${id}.dsql.us-east-1.on.aws` as const | |
const region = "us-east-1" as const |
This file contains hidden or 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
vim.api.nvim_set_keymap('n', '<SPACE>', '<NOP>', { noremap = true }) | |
vim.g.mapleader = " " | |
if vim.g.vscode then | |
require("vscode_amplify_docs_fold_filters_commands") | |
-- VSCode extension | |
local vscode = require('vscode-neovim') | |
-- set vscode as default notifier | |
vim.notify = vscode.notify | |
-- amplify docs filters |
This file contains hidden or 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 type { PropsWithChildren } from "react" | |
import { useState, createContext, useEffect, useContext } from "react" | |
import { useAuthenticator } from "@aws-amplify/ui-react" | |
import { fetchUserAttributes } from "aws-amplify/auth" | |
type UserProfile = { | |
/** | |
* the sub | |
*/ | |
id: string |
This file contains hidden or 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 type { APIGatewayProxyEventV2 } from "aws-lambda" | |
import busboy from "busboy" | |
// https://github.com/francismeynard/lambda-multipart-parser/blob/master/index.js | |
async function parseUrlEncodedFormEvent<T>( | |
event: APIGatewayProxyEventV2, | |
): Promise<T> { | |
return new Promise((resolve, reject) => { | |
const fields: Record<string, unknown> = {} | |
const bb = busboy({ headers: event.headers }) |
This file contains hidden or 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
function createStore<T = unknown>(initial?: T) { | |
type Subscriber = (state: T) => void | |
let previous: T | |
let current: T | |
let _subscriber: Subscriber | |
if (initial) current = initial | |
const update = (state: T) => { | |
previous = current |
This file contains hidden or 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 { AssumeRoleCommand, STSClient } from '@aws-sdk/client-sts' | |
export type fetchAwsCredentialsOptions = { | |
/** | |
* AWS Region to use | |
* @default {process.env.AWS_REGION} | |
*/ | |
region: string | |
} |
This file contains hidden or 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 { useEffect } from 'react' | |
import { useRouter } from 'next/router' | |
import { useAuthenticator, Authenticator } from '@aws-amplify/ui-react' | |
export default function LoginPage() { | |
const { user, route } = useAuthenticator((context) => [ | |
context.user, | |
context.route, | |
]) | |
const router = useRouter() |
This file contains hidden or 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
type HookData = { | |
amplify: { | |
environment: { | |
envName: string | |
projectPath: string | |
defaultEditor: string | |
} | |
command: string | |
subCommand: string | |
argv: string[] |
This file contains hidden or 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 React from 'react'; | |
import { MDXProvider as StockMDXProvider } from '@mdx-js/react'; | |
import type { PropsWithChildren } from 'react'; | |
const wrapper = ({ children, frontmatter }) => { | |
console.log('mdx page props', { props: { frontmatter } }); | |
return <Page meta={frontmatter}>{children}</Page>; | |
}; | |
const shortcodes = { |
This file contains hidden or 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 regex = /<(?<tag>[^>]*)>/; | |
/** | |
* Verifies whether the string is an HTML string | |
* @param str string to check | |
*/ | |
export const isHtmlString = (str: string): boolean => { | |
// <code>hello world</code> -> true | |
// hello <code>world</code> -> true | |
// hello world -> false |
NewerOlder