Created envars and updated config flow
This commit is contained in:
parent
0e424ec5fa
commit
d4b5a555b9
12 changed files with 56 additions and 62 deletions
2
.env
Normal file
2
.env
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
PORT=52026
|
||||||
|
REACT_APP_CAIRO_URL=https://cairo.dunestorm.net
|
1
.env.local
Normal file
1
.env.local
Normal file
|
@ -0,0 +1 @@
|
||||||
|
REACT_APP_CAIRO_URL=http://localhost:52000
|
|
@ -24,10 +24,11 @@
|
||||||
"sass": "^1.37.5"
|
"sass": "^1.37.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server/main.js",
|
"start": "node server/index.js",
|
||||||
"start:dev": "nodemon server/main.js",
|
"start:dev": "nodemon server/index.js",
|
||||||
"start:react": "PORT=52026 react-scripts start",
|
"start:react": "react-scripts start",
|
||||||
"build": "react-scripts build"
|
"build:react": "react-scripts build",
|
||||||
|
"build:all": "npm run build:react && docker-compose build"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": [
|
||||||
|
|
|
@ -5,6 +5,6 @@ const cairoUrl = process.env.CAIRO_URL || "http://cairo.dunestorm.net:52000";
|
||||||
const nubianUrl = process.env.NUBIAN_URL || "http://nubian.dunestorm.net:52001";
|
const nubianUrl = process.env.NUBIAN_URL || "http://nubian.dunestorm.net:52001";
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use("/", express.static("build"));
|
app.use("/", express.static("build"));
|
||||||
app.use("/api/cairo", createProxyMiddleware({ target: cairoUrl }));
|
app.use("/cairo", createProxyMiddleware({ target: cairoUrl }));
|
||||||
app.use("/api/nubian", createProxyMiddleware({ target: nubianUrl }));
|
app.use("/nubian", createProxyMiddleware({ target: nubianUrl }));
|
||||||
app.listen(port, () => console.log(`🌴 Nile server started on ${port}! 🌴`));
|
app.listen(port, () => console.log(`🌴 Nile server started on ${port}! 🌴`));
|
24
src/Stash.js
24
src/Stash.js
|
@ -1,16 +1,14 @@
|
||||||
//Module Imports
|
// Module Imports
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { ToastContainer } from "react-toastify";
|
import { ToastContainer } from "react-toastify";
|
||||||
import "react-toastify/dist/ReactToastify.css";
|
import "react-toastify/dist/ReactToastify.css";
|
||||||
//Local Imports
|
// Local Imports
|
||||||
import StashBoard from "./stash/StashBoard";
|
import StashBoard from "./stash/StashBoard";
|
||||||
import { api } from "./config.json";
|
import { api } from "./config.json";
|
||||||
|
|
||||||
const getCairoApiInstance = (cairoAuthToken) =>
|
const getCairoApiInstance = (cairoAuthToken) =>
|
||||||
axios.create({
|
axios.create({ headers: { Authorization: `Bearer ${cairoAuthToken}` } });
|
||||||
headers: { Authorization: `Bearer ${cairoAuthToken}` },
|
|
||||||
});
|
|
||||||
|
|
||||||
class Stash extends React.Component {
|
class Stash extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -28,13 +26,17 @@ class Stash extends React.Component {
|
||||||
verifyLocalToken() {
|
verifyLocalToken() {
|
||||||
const token = localStorage.getItem("cairoAuthToken");
|
const token = localStorage.getItem("cairoAuthToken");
|
||||||
axios
|
axios
|
||||||
.get(api.cairo.verify, { headers: { authorization: `Bearer ${token}` } })
|
.get(api.cairo.urls.verify, {
|
||||||
|
headers: { authorization: `Bearer ${token}` },
|
||||||
|
})
|
||||||
.then(() => this.setState({ cairoApi: getCairoApiInstance(token) }))
|
.then(() => this.setState({ cairoApi: getCairoApiInstance(token) }))
|
||||||
.catch(() =>
|
.catch((error) => {
|
||||||
window.location.replace(
|
if (error.response && error.response.status === 401)
|
||||||
`${api.cairo.login}?redirectUri=${window.location.href}`
|
return window.location.replace(
|
||||||
)
|
`${process.env.REACT_APP_CAIRO_URL}${api.cairo.urls.login}?redirectUri=${window.location.href}`
|
||||||
);
|
);
|
||||||
|
console.error("Auth server not up/configured properly!");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocalToken(cairoAuthToken) {
|
setLocalToken(cairoAuthToken) {
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
{
|
{
|
||||||
"api": {
|
"api": {
|
||||||
"cairo": {
|
"cairo": {
|
||||||
"verify": "/api/cairo/user/data",
|
"urls": {
|
||||||
"login": "http://cairo.dunestorm.net:52000/login"
|
"verify": "/cairo/api/user/data",
|
||||||
|
"login": "/cairo/login"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nubian": {
|
||||||
|
"urls": {
|
||||||
|
"files": "/nubian/api/stash/files",
|
||||||
|
"upload": "/nubian/api/stash/upload",
|
||||||
|
"download": "/nubian/api/stash/download",
|
||||||
|
"delete": "/nubian/api/stash/delete",
|
||||||
|
"public": "/nubian/api/stash/public"
|
||||||
|
},
|
||||||
|
"misc": {
|
||||||
|
"uploadField": "user-selected-file"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@ const cairoUrl = process.env.CAIRO_URL || "http://cairo.dunestorm.net:52000";
|
||||||
const nubianUrl = process.env.NUBIAN_URL || "http://nubian.dunestorm.net:52001";
|
const nubianUrl = process.env.NUBIAN_URL || "http://nubian.dunestorm.net:52001";
|
||||||
module.exports = (app) => {
|
module.exports = (app) => {
|
||||||
// Cairo Proxy
|
// Cairo Proxy
|
||||||
app.use("/api/cairo", createProxyMiddleware({ target: cairoUrl }));
|
app.use("/cairo", createProxyMiddleware({ target: cairoUrl }));
|
||||||
app.use("/api/nubian", createProxyMiddleware({ target: nubianUrl }));
|
app.use("/nubian", createProxyMiddleware({ target: nubianUrl }));
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
//Module Imports
|
// Module Imports
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
//Local Imports
|
// Local Imports
|
||||||
import Stashbar from "./Stashbar";
|
import Stashbar from "./Stashbar";
|
||||||
import StashUpload from "./StashUpload";
|
import StashUpload from "./StashUpload";
|
||||||
import StashContextMenu from "./StashContextMenu";
|
import StashContextMenu from "./StashContextMenu";
|
||||||
import { serverUrls } from "./api.json";
|
import { api } from "../config.json";
|
||||||
import "./scss/Stash.scss";
|
import "./scss/Stash.scss";
|
||||||
//Constants
|
// Constants
|
||||||
const filesUrl = `${serverUrls.GET.filesUrl}`;
|
|
||||||
//Class
|
|
||||||
|
|
||||||
const buildFilebox = (file, index) => ({
|
const buildFilebox = (file, index) => ({
|
||||||
file,
|
file,
|
||||||
selected: false,
|
selected: false,
|
||||||
|
@ -37,7 +34,7 @@ class StashBoard extends React.Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
window.cairoApi
|
window.cairoApi
|
||||||
.get(filesUrl)
|
.get(api.nubian.urls.files)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data === undefined || res.data.length === undefined)
|
if (res.data === undefined || res.data.length === undefined)
|
||||||
return toast.error("Error Loading Files");
|
return toast.error("Error Loading Files");
|
||||||
|
|
|
@ -11,11 +11,11 @@ import {
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
//Local Imports
|
//Local Imports
|
||||||
import "./scss/stash/StashContextMenu.scss";
|
import "./scss/stash/StashContextMenu.scss";
|
||||||
import { serverUrls } from "./api.json";
|
import { api } from "../config.json";
|
||||||
//Constants
|
//Constants
|
||||||
const downloadUrl = `${serverUrls.POST.downloadUrl}`;
|
const downloadUrl = api.nubian.urls.download;
|
||||||
const deleteUrl = `${serverUrls.POST.deleteUrl}`;
|
const deleteUrl = api.nubian.urls.delete;
|
||||||
const publicUrl = `${serverUrls.POST.publicUrl}`;
|
const publicUrl = api.nubian.urls.public;
|
||||||
|
|
||||||
export default class StashContextMenu extends React.Component {
|
export default class StashContextMenu extends React.Component {
|
||||||
infoView() {
|
infoView() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import Dropzone from "react-dropzone";
|
import Dropzone from "react-dropzone";
|
||||||
import FileDisplay from "./FileDisplay";
|
import FileDisplay from "./FileDisplay";
|
||||||
|
|
||||||
import "./scss/stash/StashDropzone.scss";
|
import "./scss/stash/StashDropzone.scss";
|
||||||
class StashDropzone extends React.Component {
|
class StashDropzone extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
//Module Imports
|
// Module Imports
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { CancelToken } from "axios";
|
import { CancelToken } from "axios";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
//Local Imports
|
// Local Imports
|
||||||
import StashDropzone from "./StashDropzone";
|
import StashDropzone from "./StashDropzone";
|
||||||
import StashUploadDialog from "./uploader/StashUploadDialog";
|
import StashUploadDialog from "./uploader/StashUploadDialog";
|
||||||
//Constants
|
// Constants
|
||||||
import { serverUrls, serverFields } from "./api.json";
|
import { api } from "../config.json";
|
||||||
const uploadUrl = `${serverUrls.POST.uploadUrl}`;
|
const uploadUrl = api.nubian.urls.upload;
|
||||||
const uploadField = serverFields.uploadField;
|
const uploadField = api.nubian.misc.uploadField;
|
||||||
const cancelMessage = "User Canceled";
|
const cancelMessage = "User Canceled";
|
||||||
const successClearTime = 200;
|
const successClearTime = 200;
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"serverUrls": {
|
|
||||||
"POST": {
|
|
||||||
"uploadUrl": "/api/nubian/stash/upload",
|
|
||||||
"downloadUrl": "/api/nubian/stash/download",
|
|
||||||
"deleteUrl": "/api/nubian/stash/delete",
|
|
||||||
"publicUrl": "/api/nubian/stash/public"
|
|
||||||
},
|
|
||||||
"GET": {
|
|
||||||
"filesUrl": "/api/nubian/stash/files",
|
|
||||||
"rawUrl": "/api/nubian/stash/raw"
|
|
||||||
},
|
|
||||||
"api": {
|
|
||||||
"cairo": {
|
|
||||||
"verify": "/api/cairo/user/data"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"serverFields": {
|
|
||||||
"uploadField": "user-selected-file"
|
|
||||||
}
|
|
||||||
}
|
|
Reference in a new issue