Fixed config flow & moved Nodemon config to pkg
This commit is contained in:
parent
e6009c5ac0
commit
8e4874bbf0
6 changed files with 25 additions and 10 deletions
|
@ -14,7 +14,7 @@ services:
|
||||||
- "52001:52001"
|
- "52001:52001"
|
||||||
environment:
|
environment:
|
||||||
- ALEXANDRIA_DATABASE_PASSWORD=${ALEXANDRIA_DATABASE_PASSWORD}
|
- ALEXANDRIA_DATABASE_PASSWORD=${ALEXANDRIA_DATABASE_PASSWORD}
|
||||||
|
- CAIRO_URL=http://cairo.dunestorm.net:52000
|
||||||
alexandria.dunestorm.net:
|
alexandria.dunestorm.net:
|
||||||
image: mongo
|
image: mongo
|
||||||
environment:
|
environment:
|
||||||
|
|
14
package.json
14
package.json
|
@ -28,5 +28,19 @@
|
||||||
"multer": "^1.4.2",
|
"multer": "^1.4.2",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"rimraf": "^3.0.2"
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,6 @@ function createUser(cairoId) {
|
||||||
|
|
||||||
function getUserByCairoId(cairoId) {
|
function getUserByCairoId(cairoId) {
|
||||||
return users.findOne({ cairoId }).then((user) => {
|
return users.findOne({ cairoId }).then((user) => {
|
||||||
console.log("FOUND vvvv", user);
|
|
||||||
if (!user) return createUser(cairoId);
|
if (!user) return createUser(cairoId);
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,7 +34,7 @@ function deleteFiles(cairoId, targetFiles) {
|
||||||
try {
|
try {
|
||||||
fremove(file.path);
|
fremove(file.path);
|
||||||
} catch (e) {
|
} 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}`);
|
deleteFails.push(`${file._id}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
"Server": {
|
"Server": {
|
||||||
"Port": 52001,
|
"Port": 52001,
|
||||||
"Debug": false,
|
"Debug": false,
|
||||||
"BodyLimit": "5mb",
|
"BodyLimit": "5mb"
|
||||||
"authServer": "http://cairo.dunestorm.net:52000/api/user/data"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,11 @@ const cairoMiddleware = (req, res, next) => {
|
||||||
if (req.token == null) return next();
|
if (req.token == null) return next();
|
||||||
else
|
else
|
||||||
axios
|
axios
|
||||||
.get(config.Server.authServer, {
|
.get(`${process.env.CAIRO_URL}/user/data`, {
|
||||||
headers: { authorization: `Bearer ${req.token}` },
|
headers: { authorization: `Bearer ${req.token}` },
|
||||||
})
|
})
|
||||||
.then((authRes) => {
|
.then((authRes) => {
|
||||||
if (authRes.status !== 200) return res.sendStatus(authres.status);
|
if (authRes.data && authRes.data.id) {
|
||||||
if (authRes.data != null && authRes.data.id != null) {
|
|
||||||
asUser.load(authRes.data.id).then((user) => {
|
asUser.load(authRes.data.id).then((user) => {
|
||||||
req.user = user;
|
req.user = user;
|
||||||
next();
|
next();
|
||||||
|
@ -26,8 +25,12 @@ const cairoMiddleware = (req, res, next) => {
|
||||||
} else res.status(500).json(authRes.data);
|
} else res.status(500).json(authRes.data);
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (e.response != null) res.sendStatus(e.response.status);
|
if (e.response)
|
||||||
else res.sendStatus(500);
|
return res
|
||||||
|
.status(401)
|
||||||
|
.send(`Auth server responded with: ${e.response.status}`);
|
||||||
|
console.error(e);
|
||||||
|
res.sendStatus(500);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue