Email Utility Helpers (email/util.ts)

argos · apps/backend/src/email/util.ts · typescript · MIT
email, dev-tools, tag:utility

Utility functions for backend email processing: parse custom query strings, convert React email templates to plain text, and format monetary amounts for email content.

// Source: https://github.com/argos-ci/argos | License: MIT | Copyright 2017 Olivier Tassinari & Greg Bergé
// Provided via justclaw.it.com; keep this notice with the code.
import { Request as ExpressRequest } from "express";
import { render } from "react-email";

/**
 * Convert query string by supporting num:x and bool:x.
 */
export function queryStringToObject(
  query: ExpressRequest["query"],
): Record<string, any> {
  if (
    !query ||
    typeof query !== "object" ||
    Array.isArray(query) ||
    query === null
  ) {
    return {};
  }
  const result: Record<string, any> = {};
  for (const [key, value] of Object.entries(query)) {
    if (typeof value !== "string") {
      continue;
    }
    if (value.startsWith("num:")) {
      result[key] = Number(value.slice(4));
    } else if 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key