12 implement twilio sms (#37)

* add twilio sdk

* add twilio config

use app version in config

* remove default config

* phone regex

* bun update

* create client

* fix env var

* create Textarea component

* move TextInput

* allow snippets on labels

* update with label and error

* move button

* make button children snippet

* add form props

* allow region code

* add twilio FROM number

* rename to twilioClient

* implement simple messaging

* add twilio phone number as empty var

* format

* move twilio client to local on requests

* fix story

* on second thought, dont use locals since we are only using twilio in one place

Don't want to init a twilio client on every request when its only used
in on a single page

* use i18n for page text

* validate env with a script

* remove Zod validation when loading env vars
This commit is contained in:
Baobeld 2025-01-02 20:11:27 -05:00 committed by GitHub
parent a4d998665b
commit 1c5b37b24b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 418 additions and 119 deletions

19
scripts/validate-env.ts Normal file
View file

@ -0,0 +1,19 @@
import { PhoneRegex } from '../src/lib/regex/phone';
import { z } from 'zod';
const ValidateEnvironment = () => {
const { success, error } = z
.object({
TWILIO_ACCOUNT_SID: z.string().min(1),
TWILIO_AUTH_TOKEN: z.string().min(1),
TWILIO_PHONE_NUMBER: z.string().regex(PhoneRegex),
})
.safeParse(process.env);
if (!success) {
console.error(error.message);
process.exit(1);
}
};
ValidateEnvironment();