Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api/contact/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { checkRateLimit } from "@vercel/firewall"
import { setCorsHeaders } from "./cors.js";
import { isValidBody } from "./validation.js";
import { getEmailConfig, sendEmail } from "./email.js";
import { config } from "./config.js";
import { setCorsHeaders } from "@/src/cors.js";
import { isValidBody } from "@/src/validation.js";
import { getEmailConfig, sendEmail } from "@/src/email.js";
import { config } from "@/src/config.js";

export default async (req: VercelRequest, res: VercelResponse): Promise<void> => {
const cors = setCorsHeaders(req, res, config.allowedOrigins);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "contact-api",
"type": "module",
"version": "1.1.0",
"version": "1.1.1",
"description": "Deployable contact form API",
"author": "Mason L'Etoile",
"license": "MIT",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/contact/cors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi } from "vitest";
import { setCorsHeaders } from "@/api/contact/cors.js";
import { setCorsHeaders } from "@/src/cors.js";
import type { VercelRequest, VercelResponse } from "@vercel/node";

const makeReq = (origin?: string, method = "POST") => ({
Expand Down
4 changes: 2 additions & 2 deletions tests/contact/email.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vi, describe, it, expect, beforeEach } from "vitest";
import type { Resend } from "resend";
import { getEmailConfig, sendEmail, type EmailConfig } from "@/api/contact/email.js";
import type { ContactBody } from "@/api/contact/types.js";
import { getEmailConfig, sendEmail, type EmailConfig } from "@/src/email.js";
import type { ContactBody } from "@/src/types.js";

vi.mock("resend");

Expand Down
14 changes: 7 additions & 7 deletions tests/contact/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { vi, describe, it, expect, beforeEach } from "vitest";
import type { VercelRequest, VercelResponse } from "@vercel/node";

vi.mock("@vercel/firewall", () => ({ checkRateLimit: vi.fn() }));
vi.mock("@/api/contact/cors.js", () => ({ setCorsHeaders: vi.fn() }));
vi.mock("@/api/contact/validation.js", () => ({ isValidBody: vi.fn() }));
vi.mock("@/api/contact/email.js", () => ({ getEmailConfig: vi.fn(), sendEmail: vi.fn() }));
vi.mock("@/api/contact/config.js", () => ({ config: { allowedOrigins: ["https://example.com"] } }));
vi.mock("@/src/cors.js", () => ({ setCorsHeaders: vi.fn() }));
vi.mock("@/src/validation.js", () => ({ isValidBody: vi.fn() }));
vi.mock("@/src/email.js", () => ({ getEmailConfig: vi.fn(), sendEmail: vi.fn() }));
vi.mock("@/src/config.js", () => ({ config: { allowedOrigins: ["https://example.com"] } }));

import { checkRateLimit } from "@vercel/firewall";
import { setCorsHeaders } from "@/api/contact/cors.js";
import { isValidBody } from "@/api/contact/validation.js";
import { getEmailConfig, sendEmail } from "@/api/contact/email.js";
import { setCorsHeaders } from "@/src/cors.js";
import { isValidBody } from "@/src/validation.js";
import { getEmailConfig, sendEmail } from "@/src/email.js";
import handler from "@/api/contact/index.js";

const makeReq = (overrides: Partial<VercelRequest> = {}): VercelRequest => ({
Expand Down
2 changes: 1 addition & 1 deletion tests/contact/validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { EMAIL_REGEX, isValidBody } from "@/api/contact/validation.js";
import { EMAIL_REGEX, isValidBody } from "@/src/validation.js";

describe("EMAIL_REGEX", () => {
const validate = (email: string) => EMAIL_REGEX.test(email);
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
}
},
"include": [
"./api/**/*.ts"
"./api/**/*.ts",
"./src/**/*.ts"
],
"exclude": [
"dist/",
Expand Down
Loading