1.1.4 • Published 5 years ago

@fbeta/helper v1.1.4

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

Fbeta Helper Management

npm version


Installation

Install with npm:

# Install package

$  npm install @fbeta/helper

Import module

const fbetaHelper = require("@fbeta/helper");

callAPI

Set environment variables

// Use the .env file

BASE_URL: "http://localhost:3000";

Usage

  const { callApi } = fbetaHelper;

  // GET method
  callApi.get('http://localhost:3000');

  // POST method
  const data = {};
  const config =  {
    headers: {
      Authorization: token,
  };

  callApi.post('http://localhost:3000', data, header, config);

Send mail

Set environment variables

// Use the .env file

PORT_SENDER = 1234;
HOST_SENDER = mail.smtp.com;
USER_SENDER = username;
PASS_SENDER = password;

// Or use the configEmail

const configEmail = {
  port: 1234,
  host: "mail.smtp.com",
  user: "username",
  pass: "password",
};

Usage

const { sendEmail } = fbetaHelper;

const sendMailData = {
  template: "success.html", // Email template name is required
  subject: "Congratulation", // Email subject is required
  email: "email@example.com", // Email address of the recipient is required
  data: {
    url: "http://localhost:3000",
    name: "",
    content: "",
  }, // Email content may be empty
};

try {
  sendEmail(sendMailData, configEmail);
  // => Return promise
} catch (err) {
  console.log("err", err);
}
Email template name

success.html

  const data {
    url: "http://localhost:3000", // Link button
  }

  sendMailData.data = data;

verify-email.html

  const data {
    url: "http://localhost:3000", // Link of the active button
  }

  sendMailData.data = data;

forgot-password.html

  const data {
    url: "http://localhost:3000", // Link of the active button
  }

  sendMailData.data = data;

message.html

  const data {
    url: "http://localhost:3000", // Link of the active button
    name: "Tùng Duy", // Your name
    customer_name: "John", // Your partner name
    customer_email: "john@example.com", // Your partner email
    phone: "0123456789", // Your partner phone number
    content: "Lorem...." // Content email
  }

  sendMailData.data = data;
API Documentation

sendEmail exposes the following api:

sendEmail(sendMailData, configEmail)

The exported sendEmail function takes a sendMailData object and one optional argument. The configEmail is an object, If environment variables are used, this option can be left blank.

sendMailData (Object):

Default: { template, subject, email, data }

configEmail (Object):

Default: { port, host, user, pass }


Authors and acknowledgment

  • Project manager: tungdd5@fpt.com.vn

Support

Reach out to me at one of the following places!

License

Copyright © 2020 FPT VPN. Crafted with :heart: by Fbeta.tech - tungdd5@fpt.com.vn. Released under the MIT License.


This file was generated by Tùng Duy, v1.1.0, on May 10, 2020.

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago