A MyOwnFreeHost client that you can use with server-side javascript.
With npm:
npm install 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.
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'));
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'));
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'));
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'));
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'));
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'));
Licensed under the MIT License