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 { | |
MongoClientOptions, | |
MongoClient, | |
Db, | |
FilterQuery, | |
FindOneOptions, | |
OptionalId, | |
CollectionInsertOneOptions, | |
FindOneAndUpdateOption, | |
UpdateQuery, |
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
export default class CustomError extends Error { | |
code = ''; | |
errors: { [key: string]: string[] } = {}; | |
length = 0; | |
constructor(message: string, code: string) { | |
super(message); | |
this.code = code; | |
} | |
setError = (key: string, message: 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
// this is a simulation of react-i18n's API | |
import React, { ComponentType } from 'react'; | |
import get from 'lodash/get'; | |
import { Diff } from 'utility-types'; | |
type Labels = { [key: string]: string }; | |
export type WithTranslation = { t: (key: string) => string }; | |
export const t = (labels: Labels) => (key: string): string => get(labels, key, key); |
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'; | |
export interface AsyncHandlerProps<T> { | |
handler: () => Promise<T>; | |
children(res: { | |
state: State<T>; | |
execute: () => Promise<void>; | |
}): React.ReactNode; | |
} |
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 Chart, {ChartDataSets} from 'chart.js'; | |
import styles from './styles'; | |
interface Props { | |
labels: string[]; | |
datasets: ChartDataSets[]; | |
} | |
class Graph extends React.Component<Props> { |
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
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key | |
# Don't add passphrase | |
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub | |
cat jwtRS256.key | |
cat jwtRS256.key.pub |
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 { View, Text, Dimensions } from "react-native"; | |
import Modal from "react-native-modal"; | |
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome"; | |
import { TouchableOpacity } from "react-native-gesture-handler"; | |
import { faCheckCircle, faCircle } from "@fortawesome/free-regular-svg-icons"; | |
import styles from "./styles"; | |
const { width } = Dimensions.get("window"); |
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 DatePicker from "react-datepicker"; | |
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | |
import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons"; | |
import "react-datepicker/dist/react-datepicker.css"; | |
import styles from "./styles.module.css"; | |
interface Props<Key> { | |
id: Key; | |
value?: Date | null; |
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
async function createToken(tokenParams: CustomerCreateInput) { | |
const [month, year] = tokenParams.expiry.split('/'); | |
const res = await fetch('https://api.conekta.io/tokens', { | |
method: 'POST', | |
body: JSON.stringify({ | |
card: { | |
number: tokenParams.number.replace(/\s/g, ''), | |
cvc: tokenParams.cvc, | |
exp_month: month, | |
exp_year: year, |
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"; | |
export interface FormHandlerChildrenProps<T> { | |
state: FormState<T>; | |
reload?: () => Promise<void>; | |
create?: () => Promise<void>; | |
update?: () => Promise<void>; | |
remove?: () => void; | |
onChange: (change: { id: string; value: any }) => void; | |
setModal: (name: string) => void; |