Fixed config flow & moved Nodemon config to pkg

This commit is contained in:
Dunemask 2021-08-14 21:42:17 -06:00
parent e6009c5ac0
commit 8e4874bbf0
6 changed files with 25 additions and 10 deletions

View file

@ -14,7 +14,7 @@ services:
- "52001:52001"
environment:
- ALEXANDRIA_DATABASE_PASSWORD=${ALEXANDRIA_DATABASE_PASSWORD}
- CAIRO_URL=http://cairo.dunestorm.net:52000
alexandria.dunestorm.net:
image: mongo
environment:

View file

@ -28,5 +28,19 @@
"multer": "^1.4.2",
"path": "^0.12.7",
"rimraf": "^3.0.2"
},
"nodemonConfig": {
"restartable": "rs",
"ignore": [
".git",
"./src/uploads/",
"./src/zips/"
],
"verbose": true,
"ext": "js,json",
"signal": "SIGINT",
"env": {
"CAIRO_URL": "http://localhost:52000"
}
}
}

View file

@ -100,7 +100,6 @@ function createUser(cairoId) {
function getUserByCairoId(cairoId) {
return users.findOne({ cairoId }).then((user) => {
console.log("FOUND vvvv", user);
if (!user) return createUser(cairoId);
return user;
});

View file

@ -34,7 +34,7 @@ function deleteFiles(cairoId, targetFiles) {
try {
fremove(file.path);
} catch (e) {
console.error("Error Deleting File", file.name, "\nPath:", file.path);
console.error("Error deleting file ", file.name, "\nPath:", file.path);
deleteFails.push(`${file._id}`);
}
});

View file

@ -9,7 +9,6 @@
"Server": {
"Port": 52001,
"Debug": false,
"BodyLimit": "5mb",
"authServer": "http://cairo.dunestorm.net:52000/api/user/data"
"BodyLimit": "5mb"
}
}

View file

@ -13,12 +13,11 @@ const cairoMiddleware = (req, res, next) => {
if (req.token == null) return next();
else
axios
.get(config.Server.authServer, {
.get(`${process.env.CAIRO_URL}/user/data`, {
headers: { authorization: `Bearer ${req.token}` },
})
.then((authRes) => {
if (authRes.status !== 200) return res.sendStatus(authres.status);
if (authRes.data != null && authRes.data.id != null) {
if (authRes.data && authRes.data.id) {
asUser.load(authRes.data.id).then((user) => {
req.user = user;
next();
@ -26,8 +25,12 @@ const cairoMiddleware = (req, res, next) => {
} else res.status(500).json(authRes.data);
})
.catch((e) => {
if (e.response != null) res.sendStatus(e.response.status);
else res.sendStatus(500);
if (e.response)
return res
.status(401)
.send(`Auth server responded with: ${e.response.status}`);
console.error(e);
res.sendStatus(500);
});
};