- Initial commit
This commit is contained in:
37
app/api/index.js
Normal file
37
app/api/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const apiUrl = 'http://localhost:3001';
|
||||
|
||||
const endpoints = {
|
||||
// Events and Items
|
||||
GET_EVENTS: '/events',
|
||||
GET_ITEMS: '/items?eventId=:event_id',
|
||||
|
||||
// Auction Interactions
|
||||
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]) {
|
||||
return throw new Error('Invalid API endpoint specified');
|
||||
}
|
||||
|
||||
return `${apiUrl}${endpoints[endpoint]}${cacheBuster()}`;
|
||||
};
|
||||
Reference in New Issue
Block a user