diff --git a/apps/docs/get-started/nodejs.mdx b/apps/docs/get-started/nodejs.mdx index 89cd913..46cc076 100644 --- a/apps/docs/get-started/nodejs.mdx +++ b/apps/docs/get-started/nodejs.mdx @@ -15,19 +15,19 @@ icon: node-js ```bash npm - npm install usesend + npm install usesend-js ``` ```bash yarn - yarn add usesend + yarn add usesend-js ``` ```bash pnpm - pnpm add usesend + pnpm add usesend-js ``` ```bash bun - bun add usesend + bun add usesend-js ``` @@ -36,7 +36,7 @@ icon: node-js Get the API key from the [useSend dashboard](https://app.usesend.com/dev-settings/api-keys) and initialize the SDK ```javascript - import { UseSend } from "usesend"; + import { UseSend } from "usesend-js"; const usesend = new UseSend("us_12345"); ``` diff --git a/apps/marketing/src/app/page.tsx b/apps/marketing/src/app/page.tsx index 21bc427..7b764fe 100644 --- a/apps/marketing/src/app/page.tsx +++ b/apps/marketing/src/app/page.tsx @@ -13,7 +13,7 @@ const APP_URL = "https://app.usesend.com"; export default function Page() { return ( -
+
@@ -288,16 +288,16 @@ function Features() { } function CodeExample() { - const code = `import { Unsend } from "@unsend/sdk"; + const code = `import { UseSend } from "usesend-js"; -const unsend = new Unsend({ apiKey: process.env.UNSEND_API_KEY! }); +const usesend = new UseSend("us_12345"); -await unsend.emails.send({ - from: "hi@example.com", - to: "you@company.com", - subject: "Welcome to useSend", - template: "welcome", // or html/text - data: { name: "Ada" }, +usesend.emails.send({ + to: "hello@acme.com", + from: "hello@company.com", + subject: "useSend email", + html: "

useSend is the best open source product to send emails

", + text: "useSend is the best open source product to send emails", });`; return ( @@ -314,12 +314,12 @@ await unsend.emails.send({
-
TypeScript
+
JavaScript
diff --git a/apps/web/src/lib/constants/example-codes.ts b/apps/web/src/lib/constants/example-codes.ts deleted file mode 100644 index e3061b7..0000000 --- a/apps/web/src/lib/constants/example-codes.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { CodeBlock } from "@usesend/ui/src/code"; - -export const getSendTestEmailCode = ({ - from, - to, - subject, - body, - bodyHtml, -}: { - from: string; - to: string; - subject: string; - body: string; - bodyHtml: string; -}): Array => { - return [ - { - language: "js", - title: "Node.js", - code: `import { UseSend } from "usesend"; - -const usesend = new UseSend("us_12345"); - -// const usesend = new UseSend("us_12345", "https://app.usesend.com"); - -usesend.emails.send({ - to: "${to}", - from: "${from}", - subject: "${subject}", - html: "${bodyHtml}", - text: "${body}", -}); -`, - }, - { - language: "python", - title: "Python", - code: `import requests - -url = "https://app.usesend.com/api/v1/emails" - -payload = { - "to": "${to}", - "from": "${from}", - "subject": "${subject}", - "text": "${body}", - "html": "${bodyHtml}", -} - -headers = { - "Content-Type": "application/json", - "Authorization": "Bearer us_12345" -} - -response = requests.request("POST", url, json=payload, headers=headers) -`, - }, - { - language: "php", - title: "PHP", - code: ` "https://app.usesend.com/api/v1/emails", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "POST", - CURLOPT_POSTFIELDS => "{\\n \\"to\\": \\"${to}\\",\\n \\"from\\": \\"${from}\\",\\n \\"subject\\": \\"${subject}\\",\\n \\"replyTo\\": \\"${from}\\",\\n \\"text\\": \\"${body}\\",\\n \\"html\\": \\"${bodyHtml}\\"\\n}", - CURLOPT_HTTPHEADER => [ - "Authorization: Bearer us_12345", - "Content-Type: application/json" - ], -]); - -$response = curl_exec($curl); -$err = curl_error($curl); - -curl_close($curl); - -if ($err) { - echo "cURL Error #:" . $err; -} else { - echo $response; -} - -`, - }, - { - language: "ruby", - title: "Ruby", - code: `require 'net/http' -require 'uri' -require 'json' - -url = URI("https://app.usesend.com/api/v1/emails") - -payload = { - "to" => "${to}", - "from" => "${from}", - "subject" => "${subject}", - "text" => "${body}", - "html" => "${bodyHtml}" -}.to_json - -headers = { - "Content-Type" => "application/json", - "Authorization" => "Bearer us_12345" -} - -http = Net::HTTP.new(url.host, url.port) -http.use_ssl = true - -request = Net::HTTP::Post.new(url, headers) -request.body = payload - -response = http.request(request) - -puts response.body -`, - }, - { - language: "curl", - title: "cURL", - code: `curl -X POST https://app.usesend.com/api/v1/emails \\ --H "Content-Type: application/json" \\ --H "Authorization: Bearer us_12345" \\ --d '{"to": "${to}", "from": "${from}", "subject": "${subject}", "text": "${body}", "html": "${bodyHtml}"}'`, - }, - ]; -};