- Cleanup
This commit is contained in:
7
app/api/events.js
Normal file
7
app/api/events.js
Normal 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);
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = {}) => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) => {
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user