@fbeta/helper
v1.1.4
Published
[](https://www.npmjs.com/package/@fbeta/helper)
Downloads
14
Readme
Fbeta Helper Management
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 protected]", // 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: "[email protected]", // 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:
[email protected]
Support
Reach out to me at one of the following places!
- Website at https://fbeta.tech
- Email: [email protected]
- Phone: 0358001357
License
Copyright © 2020 FPT VPN. Crafted with :heart: by Fbeta.tech - [email protected]. Released under the MIT License.
This file was generated by Tùng Duy, v1.1.0, on May 10, 2020.
