- Cleanup

This commit is contained in:
2019-08-06 01:36:08 -04:00
parent 6e71ac688a
commit b8ddc54b99
43 changed files with 361 additions and 170 deletions

7
app/api/events.js Normal file
View File

@@ -0,0 +1,7 @@
import { API_ENDPOINTS, requestGet } from './index.js';
export const fetchEvents = (auth) => {
const path = String(API_ENDPOINTS.GET_EVENTS);
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
return requestGet(path, null, opts);
};

View File

@@ -40,7 +40,7 @@ const parseQueryParamsString = (queryParams) => {
};
const parseQueryParamsObject = (queryParams) => {
if (typeof queryParams !== 'object' && Array.isArray(queryParams)) {
if (queryParams === null || typeof queryParams !== 'object' || Array.isArray(queryParams)) {
return null;
}

View File

@@ -11,7 +11,7 @@ import { API_URL } from '../constants/constants.js';
const DefaultRequestOptions = {};
const endpoints = {
export const API_ENDPOINTS = {
// Events and Items
GET_EVENTS: '/events',
// GET_ITEMS: '/items?eventId=:event_id',
@@ -23,6 +23,9 @@ const endpoints = {
PLACE_BID: '/bids/:item_id',
PURCHASE_ITEM: '/sales',
// Login
LOGIN: '/auth',
// User/Profile
USER_SIGNUP: '/signup',
USER_PROFILE: '/users/:user_id',
@@ -42,11 +45,11 @@ const cacheBuster = () => {
};
export const getEndpointUrl = (endpoint) => {
if (!endpoints[endpoint]) {
if (!API_ENDPOINTS[endpoint]) {
throw new Error('Invalid API endpoint specified');
}
return `${API_URL}${endpoints[endpoint]}`; //`${cacheBuster()}`;
return `${API_URL}${API_ENDPOINTS[endpoint]}`; //`${cacheBuster()}`;
};
export const requestGet = (path, queryParams = [], requestOptions = {}) => {

View File

@@ -1,4 +1,4 @@
import { getEndpointUrl, requestGet } from './index.js';
import { API_ENDPOINTS, requestGet } from './index.js';
export const fetchItems = (eventId, auth) => {
const path = String(API_ENDPOINTS.GET_ITEMS).replace(/:event_id$/, eventId);

View File

@@ -0,0 +1,18 @@
import { API_ENDPOINTS, requestGet } from './index.js';
export const getEmailAvailability = (email) => {
};
export const getNomAvailaibility = (nomDeBid) => {
};
export const loginUser = (username, password) => {
const path = String(API_ENDPOINTS.LOGIN);
return requestPost({
path: API_ENDPOINTS.LOGIN,
body: { username, password },
});
};
export const registerNewUser = (user) => {
};