UNPKG

@oceans/cli

Version:

work for oceans

52 lines (37 loc) 979 B
const { API_DOMAIN } = require('../config') const utils = require('./utils') exports.login = async (username, password, apiDomain) => { if (!username) { throw new Error('login username is necessary') } if (!password) { throw new Error('login password is necessary') } if (!apiDomain) { apiDomain = API_DOMAIN } const instance = utils.getAxiosInstance(apiDomain, false) const rs = await instance.post('/api/v1/account/login', { username, password }) if (rs.status !== '0') { throw new Error(rs.message) } return rs.result } exports.auth = async (token, apiDomain) => { if (!token) { throw new Error('auth token is necessary') } if (!apiDomain) { apiDomain = API_DOMAIN } const instance = utils.getAxiosInstance(apiDomain, token) const rs = await instance.post('/api/v1/account/auth') if (rs.status !== '0') { throw new Error(rs.message) } return rs.result } exports.publish = async () => { }