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 loggerMiddleware = os | |
| .$context<{ req: Request }>() | |
| .middleware(async ({ context, next, path }) => { | |
| const start = Date.now(); | |
| const method = context.req.method; | |
| const pathname = `/${path.join("/")}`; | |
| try { | |
| const result = await next({}); | |
| const duration = Date.now() - start; |
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 { Codec } from "@repo/utils/codec"; | |
| import { deleteDB, IDBPDatabase, openDB } from "idb"; | |
| import { KeyValuePair, ScanStorageArgs, WriteOps } from "tuple-database"; | |
| import { decodeTuple, encodeTuple } from "tuple-database/helpers/codec"; | |
| import { AnySchema, Json, StorageApi } from "../types"; | |
| const version = 1; | |
| const storeName = "tupledb"; |
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 { Context, ORPCError } from "@orpc/server"; | |
| import type { | |
| StandardHandlerOptions, | |
| StandardHandlerPlugin, | |
| } from "@orpc/server/standard"; | |
| function formatNow() { | |
| return new Date().toLocaleDateString("en-US", { | |
| month: "short", | |
| day: "numeric", |
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
| class ExpoSqliteTupleStorageApi implements AsyncTupleStorageApi { | |
| private db = SQLite.openDatabase("app.db"); | |
| constructor() {} | |
| async prepare() { | |
| await this.db.execAsync( | |
| [ | |
| { | |
| sql: ` |
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 { isFunction, isSymbol } from "lodash-es"; | |
| import type { | |
| KeyValuePair, | |
| ReadOnlyTupleDatabaseClientApi, | |
| TupleTransactionApi, | |
| } from "tuple-database"; | |
| import { | |
| InMemoryTupleStorage, | |
| TupleDatabase, | |
| TupleDatabaseClient, |
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 { unionBy } from "lodash-es"; | |
| import React, { ReactElement, useEffect, useState } from "react"; | |
| import { Animated, useAnimatedValue } from "react-native"; | |
| function diffBy<T>(a: T[], b: T[], key: keyof T) { | |
| const aKeys = a.map((item) => item[key]); | |
| const bKeys = b.map((item) => item[key]); | |
| const added = b.filter((item) => !aKeys.includes(item[key])); | |
| const removed = a.filter((item) => !bKeys.includes(item[key])); |