Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 965eec7

Browse files
authored
Implement separate build step for contact form serverless function (#474)
* add debug flag to contact form * add node-fetch types * add separate tsconfig and package.json * Empty commit to trigger deploy * downgrade node-fetch to ^2.6.0 * disable debug
1 parent dab1014 commit 965eec7

File tree

7 files changed

+682
-2
lines changed

7 files changed

+682
-2
lines changed

Diff for: api/contact.ts

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import fetch from 'node-fetch';
33

44
import { validateContactForm } from './_utils';
55

6+
const DEBUG_SALESFORCE = false as const;
7+
const DEBUG_EMAIL = '' as const;
8+
69
// tslint:disable-next-line:no-default-export
710
export default async function handlerAsync(req: VercelRequest, res: VercelResponse): Promise<VercelResponse> {
811
const { body } = req;
@@ -59,6 +62,10 @@ export default async function handlerAsync(req: VercelRequest, res: VercelRespon
5962
for (const product of productOfInterest.split(',')) {
6063
bodyInit.append('00N8c00000drpLw', product);
6164
}
65+
if (DEBUG_SALESFORCE) {
66+
bodyInit.append('debug', '1');
67+
bodyInit.append('debugEmail', DEBUG_EMAIL);
68+
}
6269

6370
await fetch('https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8', {
6471
method: 'POST',

Diff for: api/package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@0x/website",
3+
"version": "1.1.0",
4+
"engines": {
5+
"node": ">16"
6+
},
7+
"private": true,
8+
"description": "0x website serverless functions",
9+
"devDependencies": {
10+
"@vercel/node": "^2.8.17",
11+
"typescript": "^4.9.5"
12+
},
13+
"dependencies": {
14+
"node-fetch": "^2.6.0"
15+
},
16+
"scripts": {
17+
"vercel-build": "tsc --project tsconfig.json"
18+
}
19+
}

Diff for: api/tsconfig.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"esModuleInterop": true,
5+
"module": "commonjs",
6+
"moduleResolution": "node",
7+
"lib": ["es6"],
8+
"rootDir": "./",
9+
"skipLibCheck": true
10+
},
11+
"include": ["./*.ts"],
12+
"exclude": ["../node_modules", "node_modules"]
13+
}

Diff for: api/yarn.lock

+629
Large diffs are not rendered by default.

Diff for: package.json

+4
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
"@types/material-ui": "^0.20.0",
160160
"@types/mersenne-twister": "^1.1.2",
161161
"@types/node": "*",
162+
"@types/node-fetch": "2",
162163
"@types/numeral": "^0.0.26",
163164
"@types/query-string": "^5.1.0",
164165
"@types/rc-slider": "^8.6.0",
@@ -226,5 +227,8 @@
226227
"hooks": {
227228
"pre-push": "yarn pre_push"
228229
}
230+
},
231+
"volta": {
232+
"node": "14.21.2"
229233
}
230234
}

Diff for: ts/components/siteWrap.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { useWindowSize } from 'react-use';
2+
// import { useWindowSize } from 'react-use';
33
import styled, { ThemeProvider } from 'styled-components';
44

55
import { Footer } from 'ts/components/footer';
@@ -33,7 +33,7 @@ export const SiteWrap: React.FC<ISiteWrapProps> = (props) => {
3333
}, []);
3434

3535
const Header = headerComponent || MainHeader;
36-
const { width: windowWidth } = useWindowSize();
36+
// const { width: windowWidth } = useWindowSize();
3737
// const isSmallScreen = windowWidth < 700;
3838

3939
const toggleMobileNav = React.useCallback(() => setIsMobileNavOpen(!isMobileNavOpen), [isMobileNavOpen]);

Diff for: yarn.lock

+8
Original file line numberDiff line numberDiff line change
@@ -2889,6 +2889,14 @@
28892889
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.7.tgz#315d570ccb56c53452ff8638738df60726d5b6ea"
28902890
integrity sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==
28912891

2892+
"@types/node-fetch@2":
2893+
version "2.6.2"
2894+
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da"
2895+
integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==
2896+
dependencies:
2897+
"@types/node" "*"
2898+
form-data "^3.0.0"
2899+
28922900
"@types/node@*":
28932901
version "10.9.4"
28942902
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.4.tgz#0f4cb2dc7c1de6096055357f70179043c33e9897"

0 commit comments

Comments
 (0)