Skip to content

Commit ba6adce

Browse files
committed
fix: default environment to production and nit changes on naming
1 parent c6dca10 commit ba6adce

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pages/api/support-create-ticket.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (!apiKeyTest) throw new Error('PLAIN_TEST_API_KEY env variable is missing');
99

1010
const isEmail = (v: string) => /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(v.trim());
1111

12-
const getPlainConfig = (env: 'testnet' | 'production'): string => {
12+
const getPlainApiKey = (env: 'testnet' | 'production'): string => {
1313
const apiKey = env === 'testnet' ? apiKeyTest : apiKeyProd;
1414

1515
if (!apiKey) {
@@ -75,12 +75,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
7575
}
7676

7777
try {
78-
const { email, text, environment } = req.body;
78+
const { email, text, environment = 'production' } = req.body;
7979

80-
if (!email || !text || !environment) {
81-
return res.status(400).json({ message: 'Email, text, and environment are required.' });
80+
if (!email || !text) {
81+
return res.status(400).json({ message: 'Email and text are required.' });
8282
}
83-
8483
if (!isEmail(email)) {
8584
return res.status(400).json({ message: 'Invalid email format.' });
8685
}
@@ -93,7 +92,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
9392
return res.status(400).json({ message: 'Invalid environment value.' });
9493
}
9594

96-
const plainConfig = getPlainConfig(environment);
95+
const plainConfig = getPlainApiKey(environment);
9796

9897
const upsertCustomerVariables = {
9998
input: {

0 commit comments

Comments
 (0)