Code Monkey home page Code Monkey logo

handsome-mofh-js's Introduction

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 protected]', '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

handsome-mofh-js's People

Contributors

srugina avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.