Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env.sample

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "nextjs-app-router-with-firebase-auth",
"name": "bossprep",
"version": "0.1.0",
"private": true,
"scripts": {
Expand Down
62 changes: 62 additions & 0 deletions src/api/questionData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { clientCredentials } from '../utils/client';

const endpoint = clientCredentials.databaseURL;

const getQuestions = () =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/questions`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const getQuestion = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/questions/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const createQuestion = (questionData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/questions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(questionData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const updateQuestion = (id, questionData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/questions/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(questionData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const deleteQuestion = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/questions/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
Comment thread
Tyler-Davenport marked this conversation as resolved.
.catch(reject);
});

export { getQuestions, getQuestion, createQuestion, updateQuestion, deleteQuestion };
73 changes: 73 additions & 0 deletions src/api/responseData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { clientCredentials } from '../utils/client';

const endpoint = clientCredentials.databaseURL;

const getResponses = () =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/responses`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const getResponsesByQuestion = (questionId) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/responses?questionId=${questionId}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const getResponse = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/responses/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const createResponse = (responseData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/responses`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(responseData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const updateResponse = (id, responseData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/responses/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(responseData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const deleteResponse = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/responses/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
Comment thread
Tyler-Davenport marked this conversation as resolved.
.catch(reject);
});

export { getResponses, getResponsesByQuestion, getResponse, createResponse, updateResponse, deleteResponse };
73 changes: 73 additions & 0 deletions src/api/trialData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { clientCredentials } from '../utils/client';

const endpoint = clientCredentials.databaseURL;

const getTrials = () =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trials`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const getTrialsByCreator = (firebaseKey) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trials?creator=${firebaseKey}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const getTrial = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trials/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const createTrial = (trialData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trials`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(trialData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const updateTrial = (id, trialData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trials/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(trialData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const deleteTrial = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trials/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
Comment thread
Tyler-Davenport marked this conversation as resolved.
.then(resolve)
.catch(reject);
});

export { getTrials, getTrialsByCreator, getTrial, createTrial, updateTrial, deleteTrial };
62 changes: 62 additions & 0 deletions src/api/trialQuestionData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { clientCredentials } from '../utils/client';

const endpoint = clientCredentials.databaseURL;

const getTrialQuestionsByUser = (firebaseKey) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trial-questions?userId=${firebaseKey}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const getTrialQuestion = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trial-questions/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const createTrialQuestion = (trialQuestionData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trial-questions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(trialQuestionData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const updateTrialQuestion = (id, trialQuestionData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trial-questions/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(trialQuestionData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const deleteTrialQuestion = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/trial-questions/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
Comment thread
Tyler-Davenport marked this conversation as resolved.
.catch(reject);
});

export { getTrialQuestionsByUser, getTrialQuestion, createTrialQuestion, updateTrialQuestion, deleteTrialQuestion };
62 changes: 62 additions & 0 deletions src/api/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { clientCredentials } from '../utils/client';

const endpoint = clientCredentials.databaseURL;

const getUsers = () =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/users`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const getUser = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/users/${id}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const createUser = (userData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/users`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const updateUser = (id, userData) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/users/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userData),
})
.then((res) => res.json())
.then(resolve)
.catch(reject);
});

const deleteUser = (id) =>
new Promise((resolve, reject) => {
fetch(`${endpoint}/users/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
})
.then((res) => res.json())
.then(resolve)
Comment thread
Tyler-Davenport marked this conversation as resolved.
.catch(reject);
});
Comment thread
Tyler-Davenport marked this conversation as resolved.

export { getUsers, getUser, createUser, updateUser, deleteUser };