Compare commits

..

No commits in common. "159aac6a2eca72384604727b21f3067727d6275e" and "449accb003f0e8b42d823effd0d417be9f210cc5" have entirely different histories.

4 changed files with 7 additions and 57 deletions

View File

@ -10,12 +10,12 @@
"http://localhost"
],
"database": {
"host": "localhost",
"host": "database",
"port": 27017,
"name": "webplay"
},
"redis": {
"host": "127.0.0.1",
"host": "redis",
"port": 6379
},
"album_cover_files": [

View File

@ -138,6 +138,11 @@ router
router
.route("/history")
.get(passport.authenticate("jwt", { session: false }), (req, res) => {
database.historyList(req.user._id, result => {
res.json(result).end();
});
})
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
let item = req.body;
item.userId = req.user._id;
@ -154,31 +159,6 @@ router
});
});
router
.route("/progress")
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
let item = req.body;
item.userId = req.user._id;
database.progress.update(item);
res.status(200).end();
});
router
.route("/progress/:parent")
.get(passport.authenticate("jwt", { session: false }), (req, res) => {
database.progress.get(req.params.parent, result => {
res.json(result).end();
});
})
.delete(passport.authenticate("jwt", { session: false }), (req, res) => {
let item = {
parentId: req.params.parent,
userId: req.user._id
}
database.progress.delete(item);
res.status(200).end();
});
router
.route("/settings")
.put(passport.authenticate("jwt", { session: false }), (req, res) => {

View File

@ -62,9 +62,6 @@ exports.artists = artists;
const boxes = require("./boxes");
exports.boxes = boxes;
const progress = require("./progress");
exports.progress = progress;
const videos = require("./videos");
exports.videos = videos;

View File

@ -1,27 +0,0 @@
const { ObjectId } = require('mongodb');
const connector = require("./CONNECTOR");
var dbo;
connector.connect().then((ret) => {
dbo = ret;
});
exports.get = function (parentId, callback) {
dbo.collection("progress")
.findOne({ parentId: parentId }, (err, result) => {
if (err) throw err;
callback(result);
});
}
exports.update = function (item) {
dbo.collection("progress").deleteMany({ userId: ObjectId(item.userId), parentId: item.parentId }, () => {
dbo.collection("progress").insertOne(item, (err) => {
if (err) throw err;
});
});
};
exports.delete = function (item) {
dbo.collection("progress").deleteMany({ userId: ObjectId(item.userId), parentId: item.parentId }, (err) => {
if (err) throw err;
});
}