mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
34 lines
644 B
JavaScript
34 lines
644 B
JavaScript
|
/**
|
||
|
* API Mocks for WebUI
|
||
|
*/
|
||
|
import logo from '../store/logo';
|
||
|
import login from '../store/login';
|
||
|
|
||
|
/**
|
||
|
* Register mock api endpoints
|
||
|
* @param {string} endpoint
|
||
|
* @returns {Promise}
|
||
|
*/
|
||
|
const register = (method = 'get', endpoint, config = {}) => {
|
||
|
|
||
|
if (endpoint === 'login' && method === 'post') {
|
||
|
return login(config);
|
||
|
}
|
||
|
|
||
|
if (endpoint === 'logo' && method === 'get') {
|
||
|
return logo();
|
||
|
}
|
||
|
|
||
|
return Promise.reject({ status: 404, data: 'Not found' });
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Bind API methods
|
||
|
*/
|
||
|
const API = ['get', 'post'].reduce((api, method) => {
|
||
|
api[method] = register.bind(null, method);
|
||
|
return api;
|
||
|
}, {});
|
||
|
|
||
|
export default API;
|