View cacheMiddleware.ts
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 type { Prisma } from "@prisma/client" | |
import { redis } from "../redis" | |
type CacheMiddlewareOptions = { | |
model: Prisma.ModelName | |
action: Prisma.PrismaAction | |
keys?: string[] | |
defaultValues?: Record<string, unknown> | |
ttlInSeconds: number | |
} |
View remix-refetch.tsx
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 { useCallback, useEffect, useState, useRef } from 'react'; | |
import { useLocation } from 'react-router-dom'; | |
import type { ActionFunction } from 'remix'; | |
import { redirect, useSubmit } from 'remix'; | |
export const action: ActionFunction = async ({ request }) => { | |
const body = new URLSearchParams(await request.text()); | |
return redirect(String(body.get('path'))); | |
}; |
View login.tsx
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 { json, ActionFunction, useActionData, Form } from "remix"; | |
import { z } from "zod"; | |
// This type infer errors from a ZodType, as produced by `flatten()` of a parsed schema. | |
type inferSafeParseErrors<T extends z.ZodType<any, any, any>, U = string> = { | |
formErrors: U[]; | |
fieldErrors: { | |
[P in keyof z.infer<T>]?: U[]; | |
}; | |
}; |
View object-to-form-data.js
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
// takes a {} object and returns a FormData object | |
var objectToFormData = function(obj, form, namespace) { | |
var fd = form || new FormData(); | |
var formKey; | |
for(var property in obj) { | |
if(obj.hasOwnProperty(property)) { | |
if(namespace) { |
View gist:0052fab554b14bbfa3ef
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
#add 'node_modules' to .gitignore file | |
git rm -r --cached node_modules | |
git commit -m 'Remove the now ignored directory node_modules' | |
git push origin <branch-name> |