feat: Add Swagger API documentation
This commit introduces Swagger API documentation for all endpoints in the application. - Installs and . - Configures Swagger in to generate and serve API documentation at . - Adds JSDoc-style Swagger annotations to all routes in and the directory (, , , , , ). - Defines a cookie-based security scheme for authenticated routes. This allows for interactive API documentation and testing via the endpoint.
This commit is contained in:
151
routes/bible.js
151
routes/bible.js
@@ -13,11 +13,47 @@ const defaultBibleId = "592420522e16049f-01";
|
||||
|
||||
//getMedia('y42zyf3').then(console.log)
|
||||
DB.getDB.then((DB) => {
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Bible
|
||||
* description: Bible API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /bible:
|
||||
* get:
|
||||
* summary: Get a list of available Bibles
|
||||
* tags: [Bible]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("", async (req, res) => {
|
||||
const bibles = await fetchAPI('bibles');
|
||||
return res.json(bibles);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /bible/books:
|
||||
* get:
|
||||
* summary: Get the books of a Bible
|
||||
* tags: [Bible]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: bibleId
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/books", async (req, res) => {
|
||||
const bibleId = req.query.bibleId || defaultBibleId;
|
||||
const bibles = await fetchAPI('bibles/' + bibleId +"/books");
|
||||
@@ -30,12 +66,56 @@ DB.getDB.then((DB) => {
|
||||
return res.json(bibles);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /bible/books/{bookId}:
|
||||
* get:
|
||||
* summary: Get details for a specific book
|
||||
* tags: [Bible]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: bookId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* - in: query
|
||||
* name: bibleId
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/books/:bookId", async (req, res) => {
|
||||
const bookId = req.params.bookId;
|
||||
const bibles = await fetchAPI('bibles/' + bibleId +"/books/" + bookId);
|
||||
return res.json(bibles);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /bible/books/{bookId}/chapters:
|
||||
* get:
|
||||
* summary: Get the chapters of a book
|
||||
* tags: [Bible]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: bookId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* - in: query
|
||||
* name: bibleId
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/books/:bookId/chapters", async (req, res) => {
|
||||
const bookId = req.params.bookId;
|
||||
const bibleId = req.query.bibleId || defaultBibleId;
|
||||
@@ -43,6 +123,28 @@ DB.getDB.then((DB) => {
|
||||
return res.json(bibles);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /bible/chapters/{chapterId}:
|
||||
* get:
|
||||
* summary: Get the content of a chapter
|
||||
* tags: [Bible]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: chapterId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* - in: query
|
||||
* name: bibleId
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/chapters/:chapterId", async (req, res) => {
|
||||
const chapterId = req.params.chapterId;
|
||||
const bibleId = req.query.bibleId || defaultBibleId;
|
||||
@@ -50,6 +152,28 @@ DB.getDB.then((DB) => {
|
||||
return res.json(bibles);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /bible/chapters/{chapterId}/verses:
|
||||
* get:
|
||||
* summary: Get the verses of a chapter
|
||||
* tags: [Bible]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: chapterId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* - in: query
|
||||
* name: bibleId
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/chapters/:chapterId/verses", async (req, res) => {
|
||||
const chapterId = req.params.chapterId;
|
||||
const bibleId = req.query.bibleId || defaultBibleId;
|
||||
@@ -57,6 +181,33 @@ DB.getDB.then((DB) => {
|
||||
return res.json(bibles);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /bible/search:
|
||||
* get:
|
||||
* summary: Search the Bible
|
||||
* tags: [Bible]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: query
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 10
|
||||
* - in: query
|
||||
* name: bibleId
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/search", async (req, res) => {
|
||||
const query = req.query.query;
|
||||
const limit = req.query.limit || 10;
|
||||
|
||||
@@ -39,6 +39,13 @@ DB.getDB.then((DB) => {
|
||||
// });
|
||||
// });
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Payments
|
||||
* description: Payment processing
|
||||
*/
|
||||
|
||||
let intent = async (req, res) => {
|
||||
const userid = req.body.userid;
|
||||
const price = req.body.price || 500;
|
||||
@@ -94,9 +101,76 @@ DB.getDB.then((DB) => {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /payments/create-payment-intent:
|
||||
* post:
|
||||
* summary: Creates a Stripe Payment Intent
|
||||
* tags: [Payments]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* userid:
|
||||
* type: string
|
||||
* price:
|
||||
* type: number
|
||||
* description:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/create-payment-intent", intent);
|
||||
/**
|
||||
* @swagger
|
||||
* /payments/intent:
|
||||
* post:
|
||||
* summary: Creates a Stripe Payment Intent (Alias for /create-payment-intent)
|
||||
* tags: [Payments]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* userid:
|
||||
* type: string
|
||||
* price:
|
||||
* type: number
|
||||
* description:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/intent", intent);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /payments/register:
|
||||
* post:
|
||||
* summary: Registers a payment after a successful Stripe transaction
|
||||
* tags: [Payments]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* userid:
|
||||
* type: string
|
||||
* result:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/register", async (req, res) => {
|
||||
const userid = req.body.userid;
|
||||
const result = req.body.result;
|
||||
|
||||
382
routes/post.js
382
routes/post.js
@@ -77,6 +77,25 @@ DB.getDB.then((DB) => {
|
||||
return mergedPosts;
|
||||
};
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Posts
|
||||
* description: Post management
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/organic:
|
||||
* get:
|
||||
* summary: Get the organic feed for the current user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/organic", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
let organicPosts = await DB.getFeed(profileid);
|
||||
@@ -86,6 +105,18 @@ DB.getDB.then((DB) => {
|
||||
return res.json(posts);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post:
|
||||
* get:
|
||||
* summary: Get the feed with promotional content
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
//Add non-organic posts
|
||||
@@ -95,6 +126,26 @@ DB.getDB.then((DB) => {
|
||||
return res.json(posts);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/tag/{tag}:
|
||||
* get:
|
||||
* summary: Get posts with a specific tag
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: tag
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
* 400:
|
||||
* description: Tag is required
|
||||
*/
|
||||
router.get("/tag/:tag", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
const tag = req.query.tag || req.params.tag;
|
||||
@@ -109,6 +160,24 @@ DB.getDB.then((DB) => {
|
||||
return res.json(posts);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/usr/{id}:
|
||||
* get:
|
||||
* summary: Get posts from a specific user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/usr/:id", async (req, res) => {
|
||||
const profileId = req.params.id;
|
||||
const viewerProdileId = getProfileId(req);
|
||||
@@ -124,6 +193,24 @@ DB.getDB.then((DB) => {
|
||||
return res.json(posts);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/usr/{id}/images:
|
||||
* get:
|
||||
* summary: Get all image posts from a user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/usr/:id/images", async (req, res) => {
|
||||
const profileid = req.params.id;
|
||||
const viewerProfileId = getProfileId(req);
|
||||
@@ -134,6 +221,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/usr/{id}/embedded:
|
||||
* get:
|
||||
* summary: Get all embedded posts from a user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/usr/:id/embedded", async (req, res) => {
|
||||
const profileid = req.params.id;
|
||||
const viewerProfileId = getProfileId(req);
|
||||
@@ -144,6 +249,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/usr/{id}/media:
|
||||
* get:
|
||||
* summary: Get all media posts from a user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/usr/:id/media", async (req, res) => {
|
||||
const profileid = req.params.id;
|
||||
const viewerProfileId = getProfileId(req);
|
||||
@@ -154,11 +277,49 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/video/{id}:
|
||||
* get:
|
||||
* summary: Get video details by ID
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/video/:id", async (req, res) => {
|
||||
videoId = req.params.id;
|
||||
return res.json([]);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post:
|
||||
* post:
|
||||
* summary: Create a new post
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
* 403:
|
||||
* description: Not authorized to post to this group
|
||||
*/
|
||||
router.post("/", async (req, res) => {
|
||||
let post = {
|
||||
profileid: getProfileId(req),
|
||||
@@ -198,6 +359,27 @@ DB.getDB.then((DB) => {
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/react:
|
||||
* post:
|
||||
* summary: React to a post
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* postid:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/react", async (req, res) => {
|
||||
let profileid = getProfileId(req);
|
||||
let postid = req.body.postid;
|
||||
@@ -212,6 +394,27 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/unreact:
|
||||
* post:
|
||||
* summary: Remove a reaction from a post
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* postid:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/unreact", async (req, res) => {
|
||||
let profileid = getProfileId(req);
|
||||
let postid = req.body.postid;
|
||||
@@ -221,6 +424,27 @@ DB.getDB.then((DB) => {
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/bookmark:
|
||||
* post:
|
||||
* summary: Bookmark a post
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* postid:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/bookmark", async (req, res) => {
|
||||
let profileid = getProfileId(req);
|
||||
let postid = req.body.postid;
|
||||
@@ -230,6 +454,27 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/unbookmark:
|
||||
* post:
|
||||
* summary: Remove a bookmark from a post
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* postid:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/unbookmark", async (req, res) => {
|
||||
let profileid = getProfileId(req);
|
||||
let postid = req.body.postid;
|
||||
@@ -239,6 +484,29 @@ DB.getDB.then((DB) => {
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/comment:
|
||||
* post:
|
||||
* summary: Add a comment to a post
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* postid:
|
||||
* type: string
|
||||
* content:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/comment/", async (req, res) => {
|
||||
let profileid = getProfileId(req);
|
||||
let postid = req.body.postid;
|
||||
@@ -258,6 +526,30 @@ DB.getDB.then((DB) => {
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/comment/react:
|
||||
* post:
|
||||
* summary: React to a comment
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* postid:
|
||||
* type: string
|
||||
* commentDate:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/comment/react", async (req, res) => {
|
||||
let userid = getProfileId(req);
|
||||
let postid = req.body.postid;
|
||||
@@ -272,6 +564,30 @@ DB.getDB.then((DB) => {
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/comment/unreact:
|
||||
* post:
|
||||
* summary: Remove a reaction from a comment
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* postid:
|
||||
* type: string
|
||||
* commentDate:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/comment/unreact", async (req, res) => {
|
||||
let profileid = getProfileId(req);
|
||||
let postid = req.body.postid;
|
||||
@@ -282,6 +598,18 @@ DB.getDB.then((DB) => {
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/images:
|
||||
* get:
|
||||
* summary: Get all image posts for the current user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/images", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
const posts = await DB.getMediaTagPostOfUser(profileid, profileid);
|
||||
@@ -291,6 +619,18 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/embedded:
|
||||
* get:
|
||||
* summary: Get all embedded posts for the current user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/embedded", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
const posts = await DB.getMediaTagPostOfUser(profileid, profileid, "@iframe:");
|
||||
@@ -300,6 +640,18 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/media:
|
||||
* get:
|
||||
* summary: Get all media posts for the current user
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/media", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
const posts = await DB.getMediaTagPostOfUser(profileid, profileid, "@youtube:|@vimeo:|@hls:");
|
||||
@@ -309,6 +661,18 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/course/recent:
|
||||
* get:
|
||||
* summary: Get recently watched media from courses
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/course/recent", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
const profile = await DB.getProfileCache(profileid);
|
||||
@@ -356,6 +720,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /post/{id}:
|
||||
* get:
|
||||
* summary: Get a specific post by ID
|
||||
* tags: [Posts]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/:id", async (req, res) => {
|
||||
const postId = req.params.id;
|
||||
const post = await DB.getPost(postId);
|
||||
|
||||
@@ -14,6 +14,36 @@ DB.getDB.then((DB) => {
|
||||
return profile.userid === String(userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Profiles
|
||||
* description: User profile management
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/mine:
|
||||
* get:
|
||||
* summary: Get all profiles for the logged-in user
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: string
|
||||
* profiles:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
*/
|
||||
router.get("/mine", async (req, res) => {
|
||||
let userid = getUserId(req);
|
||||
let profiles = await DB.getUserProfiles(userid);
|
||||
@@ -23,6 +53,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/new:
|
||||
* get:
|
||||
* summary: (DEPRECATED) Create a new profile
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: content
|
||||
* required: true
|
||||
* schema:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/new", async (req, res) => { //Deprecated please use route post("/")
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
@@ -36,6 +84,27 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user:
|
||||
* post:
|
||||
* summary: Create a new profile
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* content:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/", async (req, res) => {
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
@@ -57,6 +126,32 @@ DB.getDB.then((DB) => {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/invite:
|
||||
* post:
|
||||
* summary: Invite a new user by email
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* email:
|
||||
* type: string
|
||||
* format: email
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
* 400:
|
||||
* description: Bad request
|
||||
*/
|
||||
router.post("/invite", async (req, res) => {
|
||||
try {
|
||||
const userid = getUserId(req);
|
||||
@@ -94,6 +189,25 @@ DB.getDB.then((DB) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/invite/{email}:
|
||||
* get:
|
||||
* summary: Get invitation details for an email
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: email
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: email
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/invite/:email", async (req, res) => {
|
||||
const userid = getUserId(req);
|
||||
const email = req.params.email;
|
||||
@@ -106,6 +220,18 @@ DB.getDB.then((DB) => {
|
||||
return res.json({ status: "ok", ...r });
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups:
|
||||
* get:
|
||||
* summary: Get a list of all groups
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/groups", async (req, res) => {
|
||||
let groups = await DB.getGroups();
|
||||
return res.json({
|
||||
@@ -114,6 +240,18 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups/following:
|
||||
* get:
|
||||
* summary: Get a list of groups the current profile is following
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/groups/following", async (req, res) => {
|
||||
const profileId = getProfileId(req);
|
||||
let groups = await DB.getFollowingGroups(profileId);
|
||||
@@ -123,6 +261,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups:
|
||||
* post:
|
||||
* summary: Create a new group
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/groups", async (req, res) => {
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
@@ -137,6 +293,18 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/courses:
|
||||
* get:
|
||||
* summary: Get a list of all courses
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/courses", async (req, res) => {
|
||||
let groups = await DB.getCourses();
|
||||
return res.json({
|
||||
@@ -145,6 +313,29 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups/accept:
|
||||
* post:
|
||||
* summary: Accept a request to join a private group
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* groupid:
|
||||
* type: string
|
||||
* profileid:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/groups/accept", async (req, res) => {
|
||||
//This function should be called to accept the join request
|
||||
//of an user that attempt to join a private group.
|
||||
@@ -164,6 +355,29 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups/reject:
|
||||
* post:
|
||||
* summary: Reject a request to join a private group
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* groupid:
|
||||
* type: string
|
||||
* profileid:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/groups/reject", async (req, res) => {
|
||||
//This function should be called to reject the join request
|
||||
//of an user that attempt to join a private group.
|
||||
@@ -183,6 +397,28 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups/search:
|
||||
* get:
|
||||
* summary: Search for groups
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: query
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* - in: query
|
||||
* name: courses
|
||||
* schema:
|
||||
* type: boolean
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/groups/search", async (req, res) => {
|
||||
let query = req.query.query;
|
||||
let coursesB = req.query.courses ? true : false;
|
||||
@@ -193,6 +429,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups/{id}:
|
||||
* get:
|
||||
* summary: Get details for a specific group
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/groups/:id", async (req, res) => {
|
||||
const groupid = req.params.id;
|
||||
let groups = await DB.getGroup(groupid);
|
||||
@@ -202,6 +456,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups/{id}/subscribe:
|
||||
* get:
|
||||
* summary: Subscribe to a group
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/groups/:id/subscribe", async (req, res) => {
|
||||
const groupid = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
@@ -214,6 +486,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/groups/{id}/unsubscribe:
|
||||
* get:
|
||||
* summary: Unsubscribe from a group
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/groups/:id/unsubscribe", async (req, res) => {
|
||||
const groupid = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
@@ -224,6 +514,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/search:
|
||||
* get:
|
||||
* summary: Search for profiles
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: query
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/search", async (req, res) => {
|
||||
let query = req.query.query;
|
||||
let profiles = await DB.searchProfile(query);
|
||||
@@ -233,6 +541,29 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/setData:
|
||||
* post:
|
||||
* summary: Set custom data for a profile
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* key:
|
||||
* type: string
|
||||
* value:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/setData", (req, res) => {
|
||||
const key = req.body.key;
|
||||
const value = req.body.value;
|
||||
@@ -243,6 +574,29 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/myProfile:
|
||||
* post:
|
||||
* summary: Update the current user's profile
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* profile:
|
||||
* type: object
|
||||
* data:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/myProfile", async (req, res) => {
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
@@ -256,6 +610,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/{id}:
|
||||
* get:
|
||||
* summary: Get a specific profile by ID
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/:id", async (req, res) => {
|
||||
let profileId = req.params.id;
|
||||
let profile = await DB.getProfile(profileId);
|
||||
@@ -265,6 +637,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/{id}:
|
||||
* delete:
|
||||
* summary: Delete a profile
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.delete("/:id", async (req, res) => {
|
||||
const profileId = req.params.id;
|
||||
const userid = getUserId(req);
|
||||
@@ -278,6 +668,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/{id}/follow:
|
||||
* get:
|
||||
* summary: Follow a profile
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/:id/follow", async (req, res) => {
|
||||
let followProfileId = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
@@ -288,6 +696,24 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /user/{id}/unfollow:
|
||||
* get:
|
||||
* summary: Unfollow a profile
|
||||
* tags: [Profiles]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/:id/unfollow", async (req, res) => {
|
||||
let followProfileId = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
|
||||
100
routes/songs.js
100
routes/songs.js
@@ -15,6 +15,25 @@ DB.getDB.then((DB)=>{
|
||||
return DB.ObjectID(req.cookies.profile_id || req.query.profile_id || req.body.profile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Songs
|
||||
* description: Song management
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /songs:
|
||||
* get:
|
||||
* summary: Get all songs
|
||||
* tags: [Songs]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/", async (req, res) => {
|
||||
let profileId = req.params.id;
|
||||
let songs = await DB.getSongs();
|
||||
@@ -24,6 +43,24 @@ DB.getDB.then((DB)=>{
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /songs:
|
||||
* post:
|
||||
* summary: Create a new song
|
||||
* tags: [Songs]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/", async (req, res) => {
|
||||
let post = {
|
||||
userid: getUserId(req),
|
||||
@@ -39,6 +76,24 @@ DB.getDB.then((DB)=>{
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /songs/{id}:
|
||||
* get:
|
||||
* summary: Get a specific song by ID
|
||||
* tags: [Songs]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/:id", async (req, res) => {
|
||||
let profileId = req.params.id;
|
||||
let profile = await DB.getProfile(profileId);
|
||||
@@ -53,6 +108,24 @@ DB.getDB.then((DB)=>{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /songs/{id}:
|
||||
* delete:
|
||||
* summary: Delete a song
|
||||
* tags: [Songs]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.delete("/:id", async (req, res) => {
|
||||
const userid = getUserId(req);
|
||||
const songId = req.params.id;
|
||||
@@ -66,6 +139,33 @@ DB.getDB.then((DB)=>{
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /songs/{id}:
|
||||
* post:
|
||||
* summary: Update a song
|
||||
* tags: [Songs]
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* content:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.post("/:id", async (req, res) => {
|
||||
const userid = getUserId(req);
|
||||
const songId = req.params.id;
|
||||
|
||||
@@ -67,12 +67,51 @@ const getMedia = async (eventId) => {
|
||||
};
|
||||
|
||||
//getMedia('y42zyf3').then(console.log)
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Subsplash
|
||||
* description: Subsplash API integration
|
||||
*/
|
||||
|
||||
DB.getDB.then((DB) => {
|
||||
/**
|
||||
* @swagger
|
||||
* /subsplash/events/{calendarId}:
|
||||
* get:
|
||||
* summary: Get events from a Subsplash calendar
|
||||
* tags: [Subsplash]
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: calendarId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/events/:calendarId", async (req, res) => {
|
||||
const events = await getEvents(req.params.calendarId)
|
||||
return res.json(events);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /subsplash/media/{seriesId}:
|
||||
* get:
|
||||
* summary: Get media from a Subsplash media series
|
||||
* tags: [Subsplash]
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: seriesId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: OK
|
||||
*/
|
||||
router.get("/media/:seriesId", async (req, res) => {
|
||||
const events = await getMedia(req.params.seriesId)
|
||||
return res.json(events);
|
||||
|
||||
Reference in New Issue
Block a user