Skip to content

Instantly share code, notes, and snippets.

View huijiewei's full-sized avatar
🏠
Working from home

Huijie Wei huijiewei

🏠
Working from home
View GitHub Profile
@huijiewei
huijiewei / node-mailer-brevo-transport.ts
Last active April 4, 2024 07:03
node-mailer-brevo-transport
import { Buffer } from "node:buffer";
import { readFile } from "node:fs/promises";
import { Readable } from "node:stream";
import type { SentMessageInfo, Transport } from "nodemailer";
import type { Attachment } from "nodemailer/lib/mailer";
import type MailMessage from "nodemailer/lib/mailer/mail-message";
import { version as VERSION } from "../../../package.json";
type MailAddress = { address: string; name: string };
import Database from 'better-sqlite3';
import { type Config, type Milliseconds, type Store } from 'cache-manager';
type SqliteStoreOptions = {
sqliteFile: string;
} & Config;
type CacheObject = {
cacheKey: string;
cacheData: string;
@huijiewei
huijiewei / mergeMeta.ts
Last active March 23, 2024 04:07
This function is designed to merge metadata from Remix routes, eliminating duplicates and optimizing titles
import type { LoaderFunction, MetaFunction } from "@remix-run/node";
import type { ServerRuntimeMetaDescriptor } from "@remix-run/server-runtime";
export const mergeMeta = <
Loader extends LoaderFunction | unknown = unknown,
ParentsLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>,
>(
metaFn: MetaFunction<Loader, ParentsLoaders>,
titleJoin: string = " - ",
): MetaFunction<Loader, ParentsLoaders> => {