{"id":50928216,"url":"https://github.com/sakhile-dumisa/trailerbase-email","last_synced_at":"2026-06-17T01:06:16.355Z","repository":{"id":317603566,"uuid":"1068015363","full_name":"sakhile-dumisa/trailerbase-email","owner":"sakhile-dumisa","description":"Express email server for TrailerBase (Welcome Emails)","archived":false,"fork":false,"pushed_at":"2025-11-05T12:44:38.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-22T11:39:47.248Z","etag":null,"topics":["expressjs","nodejs","resend-email-api","rest-api"],"latest_commit_sha":null,"homepage":"https://api.trailerbase.tech/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sakhile-dumisa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-01T18:15:29.000Z","updated_at":"2025-11-05T12:44:41.000Z","dependencies_parsed_at":"2025-10-01T23:36:35.716Z","dependency_job_id":null,"html_url":"https://github.com/sakhile-dumisa/trailerbase-email","commit_stats":null,"previous_names":["dumisa-sakhile/trailerbase-email","sakhile-dumisa/trailerbase-email"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sakhile-dumisa/trailerbase-email","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakhile-dumisa%2Ftrailerbase-email","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakhile-dumisa%2Ftrailerbase-email/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakhile-dumisa%2Ftrailerbase-email/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakhile-dumisa%2Ftrailerbase-email/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sakhile-dumisa","download_url":"https://codeload.github.com/sakhile-dumisa/trailerbase-email/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakhile-dumisa%2Ftrailerbase-email/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34429555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expressjs","nodejs","resend-email-api","rest-api"],"created_at":"2026-06-17T01:06:15.618Z","updated_at":"2026-06-17T01:06:16.346Z","avatar_url":"https://github.com/sakhile-dumisa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trailerbase Email Service\n\nA small API that sends welcome emails for TrailerBase using the Resend email service.\n\n## Table of contents\n- Project overview\n- Prerequisites\n- Installation\n- Environment variables\n- Run (development \u0026 production)\n- API endpoints\n- Examples\n- Deployment\n- Troubleshooting\n\n\n## Project overview\n\nThis repository contains a lightweight Express.js API that uses the Resend SDK to send welcome emails for TrailerBase users. The service exposes a single email endpoint and a couple of health checks.\n\nKey files:\n- `server.js` – main Express server and middleware (CORS, rate limiting, helmet, morgan).\n- `routes/emailRoutes.js` – email sending route (POST `/email/api/send-email`).\n\n\n## Prerequisites\n\n- Node.js 18+ (or any Node version compatible with the packages listed in `package.json`)\n- An API key for Resend (set as `RESEND_API_KEY` in your environment)\n\n\n## Installation\n\n1. Clone the repository.\n2. Install dependencies — using pnpm (preferred):\n\n```powershell\n# enable Corepack (bundled with Node \u003e=16.14 / 18+), prepare pnpm and install\ncorepack enable; corepack prepare pnpm@latest --activate; pnpm install\n```\n\nIf you prefer npm you can still run:\n\n```powershell\nnpm install\n```\n\n\n### pnpm notes\n\n- This project now uses pnpm. A `packageManager` field is added to `package.json` and a `pnpm-lock.yaml` lockfile is included.\n- To ensure the correct pnpm version is used in CI or on another machine, use Corepack to prepare/activate the pinned version (see installation command above).\n\n\n## Environment variables\n\nCreate a `.env` file in the project root or provide environment variables by your chosen method. At minimum provide:\n\n- `RESEND_API_KEY` – required. If this is missing the server will exit on startup.\n- `PORT` – optional (default: `3000`).\n\nExample `.env`:\n\n```\nRESEND_API_KEY=your_resend_api_key_here\nPORT=3000\n```\n\n\n## Run\n\n- Development (auto-restart on changes):\n\n```powershell\npnpm run dev\n```\n\n- Production / simple start:\n\n```powershell\npnpm start\n```\n\nIf you prefer npm for running scripts you can still run the `npm` equivalents, but `pnpm` is recommended for installs and scripts to keep lockfile and workspace behavior consistent.\n\n### Local testing tip\n\nThe server exits at startup if `RESEND_API_KEY` is not set (it intentionally fails fast). For safe local testing without your production API key, you can set a temporary or test key when running the server — for example (PowerShell):\n\n```powershell\nsetx RESEND_API_KEY \"test-key\"\npnpm start\n```\n\nThis will persist the environment variable for your user. To set it for the current PowerShell session only, use:\n\n```powershell\n$env:RESEND_API_KEY = 'test-key'; pnpm start\n```\n\n\n## API endpoints\n\n- Health checks\n  - `GET /` – returns a small JSON message confirming the API is running.\n  - `GET /health` – returns `status: OK` and uptime.\n\n- Send welcome email\n  - `POST /email/api/send-email`\n  - Required body (JSON):\n    - `to` (string) – recipient email address\n    - `userName` (string) – recipient or display name used inside the message\n    - `from` (string, optional) – defaults to `welcome@api.trailerbase.tech` and the server rejects any other `from` value for safety\n\n  - Responses:\n    - `200` – email sent successfully (Resend response included)\n    - `400` – bad request / validation failure\n    - `5xx` – server or Resend error\n\n\n## Examples\n\nCurl example:\n\n```powershell\ncurl -X POST http://localhost:3000/email/api/send-email \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"to\":\"user@example.com\",\"userName\":\"User\"}'\n```\n\nNode (fetch) example:\n\n```javascript\nfetch('http://localhost:3000/email/api/send-email', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ to: 'user@example.com', userName: 'User' })\n});\n```\n\n\n## Deployment\n\nThis project is compatible with Vercel and other Node hosts. There's a `vercel.json` in the repo — if deploying to Vercel, set the `RESEND_API_KEY` environment variable in the Vercel project settings.\n\n\n## Dependencies\n\nSee `package.json` for the full list. Notable dependencies include `express`, `resend`, `dotenv`, `helmet`, `morgan`, and `express-rate-limit`.\n\n\n## Troubleshooting\n\n- If the server exits immediately: ensure `RESEND_API_KEY` is set. The server intentionally exits when the Resend client cannot be initialized.\n- If emails fail to send, check the response in the returned JSON `data` from Resend and confirm your Resend account and API key are valid.\n- For CORS issues, check `server.js` CORS `origin` list — add your origin if necessary.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakhile-dumisa%2Ftrailerbase-email","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsakhile-dumisa%2Ftrailerbase-email","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakhile-dumisa%2Ftrailerbase-email/lists"}