Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/enhancement-consolidate-api-endp…
Browse files Browse the repository at this point in the history
…oints' into staging
  • Loading branch information
campb303 committed Mar 14, 2021
2 parents 9e9e48a + c3792a0 commit 17a2847
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
16 changes: 9 additions & 7 deletions api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# Restrict cookies using SameSite=strict flag
app.config["JWT_COOKIE_SAMESITE"] = "strict"
# Restrict refresh tokens to /token/refresh endpoint
app.config["JWT_REFRESH_COOKIE_PATH"] = '/tokens/refresh'
app.config["JWT_REFRESH_COOKIE_PATH"] = '/api/tokens/refresh'
# Set the cookie key for CRSF validation string
# This is the default value. Adding it for easy reference
app.config["JWT_REFRESH_CSRF_HEADER_NAME"] = "X-CSRF-TOKEN"
Expand Down Expand Up @@ -242,12 +242,14 @@ def get(self) -> tuple:
tuple: Queues and item counts as JSON and HTTP response code.
"""
return (ECNQueue.getQueueCounts(), 200)

api.add_resource(Login, "/login")
api.add_resource(RefreshAccessToken, "/tokens/refresh")
api.add_resource(Item, "/api/<string:queue>/<int:number>")
api.add_resource(Queue, "/api/<string:queues>")
api.add_resource(QueueList, "/api/get_queues")



api.add_resource(Login, "/api/login")
api.add_resource(RefreshAccessToken, "/api/tokens/refresh")
api.add_resource(Item, "/api/data/<string:queue>/<int:number>")
api.add_resource(Queue, "/api/data/<string:queues>")
api.add_resource(QueueList, "/api/data/get_queues")

if __name__ == "__main__":
app.run()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webqueue2",
"homepage": "/qwebtest/",
"homepage": "/webqueue/q2",
"proxy": "http://localhost:5000/",
"version": "0.1.0",
"private": true,
Expand Down
6 changes: 3 additions & 3 deletions src/auth/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function login(username, password){
body: JSON.stringify({ "username": username, "password": password})
};

let loginResponse = await fetch("/login", loginInit);
let loginResponse = await fetch(`${process.env.PUBLIC_URL}/api/login`, loginInit);
let data = await loginResponse.json();

if (data === null){
Expand All @@ -44,7 +44,7 @@ export async function refresh(csrf_refresh_token){
headers: {'X-CSRF-TOKEN': csrf_refresh_token},
};

let refreshResponse = await fetch("/tokens/refresh", refreshInit);
let refreshResponse = await fetch(`${process.env.PUBLIC_URL}/api/tokens/refresh`, refreshInit);
let data = await refreshResponse.json();

if (data === null){
Expand All @@ -56,4 +56,4 @@ export async function refresh(csrf_refresh_token){
}

return data.access_token || false;
}
}
4 changes: 2 additions & 2 deletions src/components/AppView/AppView.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function AppView({ setDarkMode }){
if (selectedQueues.length === 1){
queuesToLoad = selectedQueues[0].name;
}
else if (selectedQueues.length > 0){
else {
selectedQueues.forEach( (queue, index) => (
index === 0
? queuesToLoad += queue.name
Expand Down Expand Up @@ -142,4 +142,4 @@ export default function AppView({ setDarkMode }){

AppView.propTypes = {};

AppView.defaultProps = {};
AppView.defaultProps = {};
1 change: 0 additions & 1 deletion src/components/ItemTable/ItemTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export default function ItemTable({ data, rowCanBeSelected, loading }) {
{ Header: 'Department', accessor: 'department' },
{ Header: 'Building', accessor: 'building' },
{ Header: 'Date Received', accessor: 'dateReceived', sortInverted: true, Cell: ({ value }) => <RelativeTime value={value} /> },

], []);
const tableInstance = useTable(
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/QueueSelector/QueueSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getQueueCounts = async (access_token) => {
myHeaders.append("Authorization", `Bearer ${access_token}`);
let requestOptions = { headers: myHeaders };

const apiResponse = await fetch(`/api/get_queues`, requestOptions);
const apiResponse = await fetch(`${process.env.PUBLIC_URL}/api/data/get_queues`, requestOptions);
const queueCountJson = await apiResponse.json();

return queueCountJson;
Expand Down Expand Up @@ -173,4 +173,4 @@ QueueSelector.propTypes = {
"value": PropTypes.array.isRequired,
/** Function to update state variable that manages selected queues. */
"setValue": PropTypes.func.isRequired,
};
};
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ReactDOM.render(
<CookiesProvider>
<AuthProvider>
<ItemProvider>
<Router>
<Router basename={process.env.PUBLIC_URL}>
<App />
</Router>
</ItemProvider>
Expand Down

0 comments on commit 17a2847

Please sign in to comment.