Compare commits
4 Commits
9a6e5f5e0f
...
ab90aba67b
Author | SHA1 | Date | |
---|---|---|---|
ab90aba67b | |||
|
1c8163c835 | ||
|
481966768d | ||
|
5f9d438420 |
@ -3,10 +3,20 @@ var express = require("express");
|
||||
var router = new express.Router();
|
||||
const database = require("../services/database");
|
||||
|
||||
router.route("/:id").get((req, res) => {
|
||||
database.share.byId(req.params.id, (result) => {
|
||||
res.json(result).status(200).end();
|
||||
const server = require("../server");
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
@ -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) {
|
||||
dbo.collection("shares")
|
||||
.findOne({ object_id: ObjectId(object_id) })
|
||||
|
Loading…
Reference in New Issue
Block a user