Skip to content

Commit 82ff26c

Browse files
author
Rajat
committed
MediaLit integration; Image uploads for email editor; Unified login
page;
1 parent eb522b3 commit 82ff26c

47 files changed

Lines changed: 7094 additions & 267 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/api/.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ OAUTH_SIGNING_KEY=
1515
# Used to sign open/click tracking pixel tokens.
1616
PIXEL_SIGNING_SECRET=
1717

18+
# The dashboard's own public origin (apps/web). Used to build Better Auth's
19+
# trusted origins and to allowlist the `redirect` param on this API's hosted
20+
# `/login` page (see apps/web's WEB_CLIENT and the "Unified Login Screen"
21+
# addendum in docs/replace-oauth-server-with-better-auth.md).
22+
WEB_CLIENT=http://localhost:3000
23+
24+
# Optional: parent domain shared by apps/web and apps/api in production
25+
# (e.g. sendlit.example.com, covering both app.sendlit.example.com and
26+
# api.sendlit.example.com). When set, the Better Auth session cookie is
27+
# scoped to this domain instead of being host-only, so a session started on
28+
# either subdomain's login page is valid on both. Leave unset in local dev.
29+
AUTH_COOKIE_DOMAIN=
30+
1831
# Encrypts per-team ESP (SMTP) credentials at rest (AES-256-GCM). Must decode
1932
# to 32 bytes (base64) or contain at least 32 bytes (utf8). Generate with:
2033
# openssl rand -base64 32
@@ -58,3 +71,7 @@ POSTHOG_LOG_LEVEL=
5871
POSTHOG_ERROR_CAP_PER_SOURCE_PER_MINUTE=
5972
# Reported as the deployment environment (falls back to NODE_ENV).
6073
DEPLOY_ENV=
74+
75+
# MediaLit integration for file uploads
76+
MEDIALIT_APIKEY=
77+
MEDIALIT_SERVER=https://api.medialit.cloud
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
CREATE TABLE IF NOT EXISTS "media" (
2+
"id" uuid PRIMARY KEY NOT NULL,
3+
"team_id" uuid NOT NULL,
4+
"media_id" text NOT NULL,
5+
"media_lit_id" text NOT NULL,
6+
"url" text NOT NULL,
7+
"thumbnail_url" text,
8+
"file_name" text,
9+
"mime_type" text,
10+
"size" integer,
11+
"width" integer,
12+
"height" integer,
13+
"alt" text,
14+
"caption" text,
15+
"created_at" timestamp with time zone DEFAULT now(),
16+
"updated_at" timestamp with time zone DEFAULT now(),
17+
CONSTRAINT "media_media_id_unique" UNIQUE("media_id"),
18+
CONSTRAINT "media_media_id_check" CHECK ("media"."media_id" ~ '^med_')
19+
);
20+
--> statement-breakpoint
21+
CREATE TABLE IF NOT EXISTS "media_references" (
22+
"id" uuid PRIMARY KEY NOT NULL,
23+
"team_id" uuid NOT NULL,
24+
"media_id" uuid NOT NULL,
25+
"resource_type" text NOT NULL,
26+
"resource_internal_id" uuid NOT NULL,
27+
"resource_public_id" text NOT NULL,
28+
"parent_resource_internal_id" uuid,
29+
"parent_resource_public_id" text,
30+
"created_at" timestamp with time zone DEFAULT now(),
31+
"updated_at" timestamp with time zone DEFAULT now()
32+
);
33+
--> statement-breakpoint
34+
DO $$ BEGIN
35+
ALTER TABLE "media" ADD CONSTRAINT "media_team_id_teams_id_fk" FOREIGN KEY ("team_id") REFERENCES "public"."teams"("id") ON DELETE cascade ON UPDATE no action;
36+
EXCEPTION
37+
WHEN duplicate_object THEN null;
38+
END $$;
39+
--> statement-breakpoint
40+
DO $$ BEGIN
41+
ALTER TABLE "media_references" ADD CONSTRAINT "media_references_team_id_teams_id_fk" FOREIGN KEY ("team_id") REFERENCES "public"."teams"("id") ON DELETE cascade ON UPDATE no action;
42+
EXCEPTION
43+
WHEN duplicate_object THEN null;
44+
END $$;
45+
--> statement-breakpoint
46+
DO $$ BEGIN
47+
ALTER TABLE "media_references" ADD CONSTRAINT "media_references_media_id_media_id_fk" FOREIGN KEY ("media_id") REFERENCES "public"."media"("id") ON DELETE cascade ON UPDATE no action;
48+
EXCEPTION
49+
WHEN duplicate_object THEN null;
50+
END $$;
51+
--> statement-breakpoint
52+
CREATE UNIQUE INDEX IF NOT EXISTS "media_team_id_media_lit_id_idx" ON "media" USING btree ("team_id","media_lit_id");--> statement-breakpoint
53+
CREATE INDEX IF NOT EXISTS "media_team_id_created_at_idx" ON "media" USING btree ("team_id","created_at");--> statement-breakpoint
54+
CREATE INDEX IF NOT EXISTS "media_references_resource_idx" ON "media_references" USING btree ("team_id","resource_type","resource_internal_id");--> statement-breakpoint
55+
CREATE INDEX IF NOT EXISTS "media_references_media_id_idx" ON "media_references" USING btree ("media_id");--> statement-breakpoint
56+
CREATE UNIQUE INDEX IF NOT EXISTS "media_references_resource_media_idx" ON "media_references" USING btree ("team_id","resource_type","resource_internal_id","media_id");

0 commit comments

Comments
 (0)