Skip to content

Enhancement consolidate api endpoints #183

Merged
merged 9 commits into from
Mar 14, 2021
Merged
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
12 changes: 6 additions & 6 deletions api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 @@ -186,11 +186,11 @@ def get(self) -> tuple:



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 @@ -41,7 +41,7 @@ export default function AppView({ setDarkMode }){
myHeaders.append("Authorization", `Bearer ${access_token}`);
let requestOptions = { headers: myHeaders };

const apiResponse = await fetch(`/api/${queuesToLoad}`, requestOptions);
const apiResponse = await fetch(`${process.env.PUBLIC_URL}/api/data/${queuesToLoad}`, requestOptions);
const queueJson = await apiResponse.json();
setQueues(queueJson);
} else {
Expand Down Expand Up @@ -140,4 +140,4 @@ export default function AppView({ setDarkMode }){

AppView.propTypes = {};

AppView.defaultProps = {};
AppView.defaultProps = {};
5 changes: 1 addition & 4 deletions src/components/ItemTable/ItemTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ export default function ItemTable({ data, rowCanBeSelected }) {
{ Header: 'Department', accessor: 'department' },
{ Header: 'Building', accessor: 'building' },
{ Header: 'Date Received', accessor: 'dateReceived', sortInverted: true, Cell: ({ value }) => <RelativeTime value={value} /> },
{ Header: 'Last Updated', accessor: 'lastUpdated', },
{ Header: 'Department', accessor: 'department' },
{ Header: 'Building', accessor: 'building' },
{ Header: 'Date Received', accessor: 'dateReceived', },

], []);
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,
};
};
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export const history = createBrowserHistory({
ReactDOM.render(
<React.StrictMode>
<CssBaseline />
<CookiesProvider>
<AuthProvider>
<Router>
<App />
</Router>
</AuthProvider>
</CookiesProvider>
<CookiesProvider>
<AuthProvider>
<Router basename={process.env.PUBLIC_URL}>
<App />
</Router>
</AuthProvider>
</CookiesProvider>
</React.StrictMode>,
document.getElementById('root')
);
Expand Down