mirror of
https://github.com/System-End/resolution.git
synced 2026-04-20 00:25:19 +00:00
Implement resolution submission API, initialize Airtable integration, and update package dependencies.
This commit is contained in:
parent
12625e973d
commit
894cdb9bd3
3 changed files with 1642 additions and 0 deletions
1597
resolution-frontend/package-lock.json
generated
Normal file
1597
resolution-frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
13
resolution-frontend/src/lib/server/airtable.ts
Normal file
13
resolution-frontend/src/lib/server/airtable.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import Airtable from 'airtable';
|
||||
import { AIRTABLE_API_TOKEN, AIRTABLE_BASE_ID } from '$env/static/private';
|
||||
|
||||
if (!AIRTABLE_API_TOKEN) {
|
||||
throw new Error('AIRTABLE_API_TOKEN is not defined in .env');
|
||||
}
|
||||
|
||||
if (!AIRTABLE_BASE_ID) {
|
||||
throw new Error('AIRTABLE_BASE_ID is not defined in .env');
|
||||
}
|
||||
|
||||
const client = new Airtable({ apiKey: AIRTABLE_API_TOKEN });
|
||||
export const base = client.base(AIRTABLE_BASE_ID);
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
import { AIRTABLE_API_TOKEN, AIRTABLE_BASE_ID, AIRTABLE_TABLE_ID } from '$env/static/private';
|
||||
import Airtable from 'airtable';
|
||||
import { json } from '@sveltejs/kit';
|
||||
|
||||
export async function POST({ request, getClientAddress }) {
|
||||
try {
|
||||
const { email } = await request.json();
|
||||
const ip = getClientAddress();
|
||||
|
||||
if (!email) {
|
||||
return json({ error: 'Email is required' }, { status: 400 });
|
||||
}
|
||||
|
||||
console.log(`Submitting email: ${email} from IP: ${ip}`);
|
||||
|
||||
const base = new Airtable({ apiKey: AIRTABLE_API_TOKEN }).base(AIRTABLE_BASE_ID);
|
||||
|
||||
await base(AIRTABLE_TABLE_ID).create([
|
||||
{
|
||||
"fields": {
|
||||
"Email": email,
|
||||
"IP-Addres": ip
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
return json({ success: true });
|
||||
} catch (err) {
|
||||
console.error('Airtable submission error:', err);
|
||||
return json({ error: 'Failed to submit application. Please try again.' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue