share: provide collection api fix#2
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3b91eddcdd
commit
5f9d438420
@ -10,12 +10,12 @@
|
|||||||
"http://localhost"
|
"http://localhost"
|
||||||
],
|
],
|
||||||
"database": {
|
"database": {
|
||||||
"host": "database",
|
"host": "localhost",
|
||||||
"port": 27017,
|
"port": 27017,
|
||||||
"name": "webplay"
|
"name": "webplay"
|
||||||
},
|
},
|
||||||
"redis": {
|
"redis": {
|
||||||
"host": "redis",
|
"host": "localhost",
|
||||||
"port": 6379
|
"port": 6379
|
||||||
},
|
},
|
||||||
"album_cover_files": [
|
"album_cover_files": [
|
||||||
|
@ -3,8 +3,18 @@ var express = require("express");
|
|||||||
var router = new express.Router();
|
var router = new express.Router();
|
||||||
const database = require("../services/database");
|
const database = require("../services/database");
|
||||||
|
|
||||||
router.route("/:id").get((req, res) => {
|
const server = require("../server");
|
||||||
database.share.byId(req.params.id, (result) => {
|
var passport = server.passport;
|
||||||
|
|
||||||
|
router.route("/")
|
||||||
|
.get(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||||
|
database.share.collection(result => {
|
||||||
|
res.json(result).status(200).end();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
router.route("/:id")
|
||||||
|
.get((req, res) => {
|
||||||
|
database.share.byId(req.params.id, result => {
|
||||||
res.json(result).status(200).end();
|
res.json(result).status(200).end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -42,6 +42,15 @@ exports.byId = function (id, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.collection = function (callback) {
|
||||||
|
dbo.collection("shares")
|
||||||
|
.find({})
|
||||||
|
.toArray((err, result) => {
|
||||||
|
if (err) throw err;
|
||||||
|
cb(callback, result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
exports.exists = function (object_id, callback) {
|
exports.exists = function (object_id, callback) {
|
||||||
dbo.collection("shares")
|
dbo.collection("shares")
|
||||||
.findOne({ object_id: ObjectId(object_id) })
|
.findOne({ object_id: ObjectId(object_id) })
|
||||||
|
Loading…
Reference in New Issue
Block a user