Files
Eventment/app/api/index.js

40 lines
963 B
JavaScript

const apiUrl = 'http://localhost:3001';
const endpoints = {
// Events and Items
GET_EVENTS: '/events',
// GET_ITEMS: '/items?eventId=:event_id',
GET_ITEMS: '/items',
// Auction Interactions
// GET_STATUS: '/auction/:event_id',
GET_STATUS: '/auction',
PLACE_BID: '/bids/:item_id',
PURCHASE_ITEM: '/sales',
// User/Profile
USER_SIGNUP: '/signup',
USER_PROFILE: '/users/:user_id',
// Services
APPLE_SIGNUP: '/auth/apple/login',
APPLE_LINK: '/auth/apple/link',
FACEBOOK_SIGNUP: '/auth/facebook/login',
FACEBOOK_LINK: '/auth/facebook/link',
GOOGLE_SIGNUP: '/auth/google/login',
GOOGLE_LINK: '/auth/google/link',
};
const cacheBuster = () => {
const timestamp = String(Date.now());
return `?buster=${timestamp}`;
};
export const getEndpointUrl = (endpoint) => {
if (!endpoints[endpoint]) {
throw new Error('Invalid API endpoint specified');
}
return `${apiUrl}${endpoints[endpoint]}`; //`${cacheBuster()}`;
};