Namespace Pollution Mechanism
Wondering what’s next for npm?Check out our public roadmap! »

mofh-client-js

2.0.1 • Public • Published

MOFH-Client

npm bundle size

A MyOwnFreeHost client that you can use with server-side javascript.

Install

With npm:

npm install mofh-client

configure mofh-client

In a .env file in main directory of project enter your mofh api user and mofh api key, which you can find here.

mofh_api_user='your-mofh-api-user'
mofh_api_key='your-mofh-api-key'

You will also need to set the IP your code is running on inside the panel (linked above) to be allowed to call the MOFH API.

Usage

create an account on MOFH:

const createAccount: (username: string, password: string, email: string, domain: string, plan: string) => any
  • asynchronous

  • @param username — A unique, 8 character identifier of the account.

  • @param password — their password to login to the control panel, FTP and databases.

  • @param email — their email.

  • @param domain — their domain. Can be a subdomain or a custom domain.

  • @param plan — the hosting plan to create the account on. Requires a hosting package to be configured through MyOwnFreeHost.

  • @returns — json: "success": whether or not you should be showing the response to the user. "message": { "status": 1 or 0 depending on success, "statusmsg": the response of the request, "vpusername": their vistapanel username if success, }. "error": the error, if there is one

Example:

//returns '{"success": true, "message": 1, "error": ''}'
const mofh = require('mofh-client');
console.log(mofh.createAccount('username', 'password', 'email@email.com', 'valid.domain.com', 'freeplan01'));

Get a list of a user's domains:

const getUserDomains: (username: string) => any
  • asynchronous

  • @param username — The unique, 8 character identifier of the account.

  • @returns — json: "success": whether or not you should be showing the response to the user. "message": either be empty array (i.e. an error occured or no domains found) or contain array of websites in the form of [["status e.g. ACTIVE", "the url"], etc.]. "error": the error, if there is one

Example:

//returns '{"success": true, "message": [["status e.g. ACTIVE", "the url"], etc.], "error": ''}'
const mofh = require('mofh-client');
console.log(mofh.getUserDomains('validusername'));

Get availability of a domain:

const getAvailability: (domain: string) => any
  • asynchronous

  • @param domain — The domain name or subdomain to check.

  • @returns — json: "success": whether or not you should be showing the response to the user. "message": either be 0 (not available/failed to check) or 1 (available+succeeded). "error": the error, if there is one

Example:

//returns '{"success": true, "message": 1, "error": ''}'
const mofh = require('mofh-client');
console.log(mofh.getUserDomains('valid.domain.com'));

Reset a User's Password:

const resetPassword: (username: string, password: string) => any
  • asynchronous

  • @param username — The unique, 8 character identifier of the account.

  • @param password — their new password

  • @returns — json: "success": whether or not you should be showing the response to the user. "message": { "status": 1 or 0 depending on success, "statusmsg": 'Success' or error containing response and letter x for suspended, r for reactivating, and c for closing,}. "error": the error, if there is one

Example:

//returns '{"success": true, "message": 1, "error": ''}'
const mofh = require('mofh-client');
console.log(mofh.resetPassword('username', 'newpassword'));

Suspend an Account:

const suspendAccount: (username: string, reason: string) => any
  • asynchronous

  • @param username — The unique, 8 character identifier of the account.

  • @param reason — Information about why you are suspending the account. at least 5 chars long.

  • @returns — json: "success": whether or not you should be showing the response to the user. "message": { "status": 1 or 0 depending on success, "statusmsg": non existant if success, error response if fail}. "error": the error, if there is one

Example:

//returns '{"success": true, "message": 1, "error": ''}'
const mofh = require('mofh-client');
console.log(mofh.suspendAccount('username', 'innapropriate content'));

Unsuspend an Account:

const unsuspendAccount: (username: string) => any
  • asynchronous

  • @param username — The unique, 8 character identifier of the account.

  • @returns — json: "success": whether or not you should be showing the response to the user. "message": { "status": 1 or 0 depending on success, "statusmsg": non existant if success, error response if fail}. "error": the error, if there is one

Example:

//returns '{"success": true, "message": 1, "error": ''}'
const mofh = require('mofh-client');
console.log(mofh.suspendAccount('username', 'innapropriate content'));

License

Licensed under the MIT License

Install

npm i mofh-client-js

DownloadsWeekly Downloads

4

Version

2.0.1

License

MIT

Unpacked Size

14.2 kB

Total Files

4

Last publish

Collaborators

  • avatar