@miguel-yuno/node
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@yuno-sdk-web/server

Node.js SDK Support

Documentation

Installation

    # npm
    npm install @yuno-sdk-web/server

    # Yarn
    yarn add @yuno-sdk-web/server

    #pnpm
    pnpm add @yuno-sdk-web/server

Add environment variables

# .env
ACCOUNT_CODE=
PUBLIC_API_KEY=
PRIVATE_SECRET_KEY=

Initialize YunoClient

// utils/yuno.ts
import "dotenv/config";

import { YunoClient } from "@yuno-sdk-web/server";

export const yunoClient = YunoClient.initialize({
  accountCode: process.env.ACCOUNT_CODE,
  publicApiKey: process.env.PUBLIC_API_KEY,
  privateSecretKey: process.env.PRIVATE_SECRET_KEY,
});

Using Yuno

Express.js example

// index.ts
import express from "express";
import cors from "cors";
import type { CheckoutSessionInput, CustomerInput } from "@yuno-sdk-web/server";
import "dotenv/config";
import { yunoClient } from "./utils/yuno";

const app = express();

app.use(cors());
app.use(express.json());

app.post("/checkout/sessions", async (req, res) => {
  const body = req.body as CheckoutSessionInput;

  const checkoutSession = await yunoClient.checkoutSessions.create(body);

  res.json(checkoutSession).status(200);
});

app.post("/customers", async (req, res) => {
  const body = req.body as CustomerInput;

  const customer = await yunoClient.customers.create(body);

  res.json(customer).status(200);
});

app.listen(3000, () => {
  console.log("listening on port 3000");
});

Readme

Keywords

none

Package Sidebar

Install

npm i @miguel-yuno/node

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

31.4 kB

Total Files

10

Last publish

Collaborators

  • miguelvdev