Skip to content

Commit 8557eb2

Browse files
authored
Merge pull request #1124 from constructive-io/feat/rename-email-sms-functions
refactor: rename email/SMS cloud functions to purpose-driven names
2 parents e0c6e4d + da410e3 commit 8557eb2

25 files changed

Lines changed: 176 additions & 206 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ React Query Hooks or Prisma-like ORM Client
7171
| `packages/` | Shared utilities - CLI (`cnc`), ORM base, query builder, server utils, client |
7272
| `uploads/` | File streaming - S3/MinIO, ETags, content-type detection, UUID hashing |
7373
| `jobs/` | Knative job scheduling - worker, scheduler, service, functions |
74-
| `functions/` | Knative cloud functions (e.g., send-email-link) |
74+
| `functions/` | Knative cloud functions (e.g., send-verification-link, send-email) |
7575

7676
### Key Packages & CLIs
7777

docker-compose.jobs.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ services:
7272
aliases:
7373
- constructive-server
7474

75-
# Send email link function (invite, password reset, verification)
76-
send-email-link:
77-
container_name: send-email-link
75+
# Send verification link function (invite, password reset, verification)
76+
send-verification-link:
77+
container_name: send-verification-link
7878
image: constructive:dev
79-
entrypoint: ["node", "functions/send-email-link/dist/index.js"]
79+
entrypoint: ["node", "functions/send-verification-link/dist/index.js"]
8080
environment:
8181
NODE_ENV: development
8282
LOG_LEVEL: info
@@ -98,7 +98,7 @@ services:
9898
# localhost-style hosts in DRY RUN mode:
9999
# http://localhost:LOCAL_APP_PORT/...
100100
LOCAL_APP_PORT: "3000"
101-
SEND_EMAIL_LINK_DRY_RUN: "${SEND_EMAIL_LINK_DRY_RUN:-true}"
101+
SEND_VERIFICATION_LINK_DRY_RUN: "${SEND_VERIFICATION_LINK_DRY_RUN:-true}"
102102
ports:
103103
- "8082:8080"
104104
networks:
@@ -110,7 +110,7 @@ services:
110110
image: constructive:dev
111111
entrypoint: ["node", "jobs/knative-job-service/dist/run.js"]
112112
depends_on:
113-
- send-email-link
113+
- send-verification-link
114114
environment:
115115
NODE_ENV: development
116116

@@ -124,7 +124,7 @@ services:
124124

125125
# Worker configuration
126126
JOBS_SUPPORT_ANY: "false"
127-
JOBS_SUPPORTED: "send-email-link"
127+
JOBS_SUPPORTED: "email:send_verification_link,email:send_email"
128128
HOSTNAME: "knative-job-service-1"
129129

130130
# Callback HTTP server (job completion callbacks)
@@ -134,10 +134,10 @@ services:
134134
JOBS_CALLBACK_HOST: "knative-job-service"
135135

136136
# Function gateway base URL (used by worker when no dev map is present)
137-
INTERNAL_GATEWAY_URL: "http://send-email-link:8080"
137+
INTERNAL_GATEWAY_URL: "http://send-verification-link:8080"
138138

139139
# Development-only map from task identifier -> function URL
140-
INTERNAL_GATEWAY_DEVELOPMENT_MAP: '{"send-email-link":"http://send-email-link:8080"}'
140+
INTERNAL_GATEWAY_DEVELOPMENT_MAP: '{"email:send_verification_link":"http://send-verification-link:8080","email:send_email":"http://send-email:8080"}'
141141

142142
ports:
143143
- "8080:8080"

docker-compose.local-email.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Services:
77
# - mailpit (SMTP: 1025, Web UI: 8025)
88
# - constructive-admin-server (3002)
9-
# - send-email-link (8082)
9+
# - send-verification-link (8082)
1010
# - knative-job-service (8080)
1111
#
1212
# Prerequisites:
@@ -57,11 +57,11 @@ services:
5757
networks:
5858
- constructive-net
5959

60-
# Send email link function (uses SMTP to Mailpit)
61-
send-email-link:
62-
container_name: send-email-link
60+
# Send verification link function (uses SMTP to Mailpit)
61+
send-verification-link:
62+
container_name: send-verification-link
6363
image: constructive:dev
64-
entrypoint: ["node", "functions/send-email-link/dist/index.js"]
64+
entrypoint: ["node", "functions/send-verification-link/dist/index.js"]
6565
depends_on:
6666
- mailpit
6767
- constructive-admin-server
@@ -81,19 +81,19 @@ services:
8181
# Local app port for email links
8282
LOCAL_APP_PORT: "3011"
8383
ALLOW_LOCALHOST: "true"
84-
SEND_EMAIL_LINK_DRY_RUN: "false"
84+
SEND_VERIFICATION_LINK_DRY_RUN: "false"
8585
ports:
8686
- "8082:8080"
8787
networks:
8888
- constructive-net
8989

90-
# Job service (polls app_jobs, triggers send-email-link)
90+
# Job service (polls app_jobs, triggers send-verification-link)
9191
knative-job-service:
9292
container_name: knative-job-service
9393
image: constructive:dev
9494
entrypoint: ["node", "jobs/knative-job-service/dist/run.js"]
9595
depends_on:
96-
- send-email-link
96+
- send-verification-link
9797
extra_hosts:
9898
- "host.docker.internal:host-gateway"
9999
environment:
@@ -107,15 +107,15 @@ services:
107107
JOBS_SCHEMA: app_jobs
108108
# Worker config
109109
JOBS_SUPPORT_ANY: "true"
110-
JOBS_SUPPORTED: "send-email-link"
110+
JOBS_SUPPORTED: "email:send_verification_link,email:send_email"
111111
HOSTNAME: "local-worker"
112112
# Callback server
113113
INTERNAL_JOBS_CALLBACK_PORT: "8080"
114114
INTERNAL_JOBS_CALLBACK_URL: "http://knative-job-service:8080/callback"
115115
JOBS_CALLBACK_HOST: "knative-job-service"
116116
# Function gateway
117-
INTERNAL_GATEWAY_URL: "http://send-email-link:8080"
118-
INTERNAL_GATEWAY_DEVELOPMENT_MAP: '{"send-email-link":"http://send-email-link:8080"}'
117+
INTERNAL_GATEWAY_URL: "http://send-verification-link:8080"
118+
INTERNAL_GATEWAY_DEVELOPMENT_MAP: '{"email:send_verification_link":"http://send-verification-link:8080","email:send_email":"http://send-email:8080"}'
119119
ports:
120120
- "8080:8080"
121121
networks:
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ COPY . .
2121
RUN set -eux; \
2222
pnpm install --frozen-lockfile
2323

24-
# Build the simple-email function and its dependencies
25-
ARG FUNCTION_DIR=functions/simple-email
24+
# Build the send-email function and its dependencies
25+
ARG FUNCTION_DIR=functions/send-email
2626
RUN set -eux; \
2727
pnpm --filter "./${FUNCTION_DIR}"... build
2828

@@ -40,11 +40,11 @@ RUN set -eux; \
4040
# Copy the built repo from builder (keeps pnpm workspace wiring intact)
4141
COPY --from=build /app /app
4242

43-
# simple-email function workspace directory
44-
WORKDIR /app/functions/simple-email
43+
# send-email function workspace directory
44+
WORKDIR /app/functions/send-email
4545

4646
ENV NODE_ENV=production
4747

48-
# Entry point for the simple-email function
48+
# Entry point for the send-email function
4949
CMD ["node", "dist/index.js"]
5050

File renamed without changes.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @constructive-io/simple-email-fn
1+
# @constructive-io/send-email-fn
22

33
<p align="center" width="100%">
44
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
@@ -9,7 +9,7 @@
99
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
1010
</a>
1111
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12-
<a href="https://www.npmjs.com/package/@constructive-io/simple-email-fn"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=functions%2Fsimple-email%2Fpackage.json"/></a>
12+
<a href="https://www.npmjs.com/package/@constructive-io/send-email-fn"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=functions%2Fsend-email%2Fpackage.json"/></a>
1313
</p>
1414

1515
Simple Knative-compatible email function used with the Constructive jobs system.
@@ -21,7 +21,7 @@ without needing a real mail provider configured.
2121

2222
## Expected job payload
2323

24-
Jobs should use `task_identifier = 'simple-email'` (or whatever route you
24+
Jobs should use `task_identifier = 'email:send_email'` (or whatever route you
2525
configure at your Knative gateway) and a JSON payload like:
2626

2727
```json
@@ -78,7 +78,7 @@ Email provider configuration is only required when not running in dry‑run mode
7878

7979
Optional:
8080

81-
- `SIMPLE_EMAIL_DRY_RUN` (`true`/`false`): log only, skip send.
81+
- `SEND_EMAIL_DRY_RUN` (`true`/`false`): log only, skip send.
8282
- `EMAIL_SEND_USE_SMTP` (`true`/`false`): use SMTP (`simple-smtp-server`).
8383

8484
Mailgun (`@launchql/postmaster`) env vars when `EMAIL_SEND_USE_SMTP` is false:
@@ -100,7 +100,7 @@ SMTP env vars when `EMAIL_SEND_USE_SMTP` is true:
100100
From the repo root:
101101

102102
```bash
103-
pnpm --filter="@constructive-io/simple-email-fn" build
103+
pnpm --filter="@constructive-io/send-email-fn" build
104104
```
105105

106106
This compiles TypeScript into `dist/`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@constructive-io/simple-email-fn",
2+
"name": "@constructive-io/send-email-fn",
33
"version": "1.11.0",
44
"description": "Simple Knative email function that sends emails directly from job payload",
55
"author": "Constructive <developers@constructive.io>",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const getRequiredField = (
2727
return value;
2828
};
2929

30-
const isDryRun = parseEnvBoolean(process.env.SIMPLE_EMAIL_DRY_RUN) ?? false;
30+
const isDryRun = parseEnvBoolean(process.env.SEND_EMAIL_DRY_RUN ?? process.env.SIMPLE_EMAIL_DRY_RUN) ?? false;
3131
const useSmtp = parseEnvBoolean(process.env.EMAIL_SEND_USE_SMTP) ?? false;
32-
const logger = createLogger('simple-email');
32+
const logger = createLogger('send-email');
3333
const app = createJobApp();
3434

3535
app.post('/', async (req: any, res: any, next: any) => {

0 commit comments

Comments
 (0)