diff --git a/routes/create.js b/routes/create.js index 97b8697..386724f 100644 --- a/routes/create.js +++ b/routes/create.js @@ -5,6 +5,15 @@ const router = express.Router() import controller from '../db-controller.js' import auth from '../auth/index.js' +/** + * POST /v1/api/create - Create new object + * Requires JWT authentication + * + * @param {object} req.body - JSON object to create + * @param {string} [req.body.@context] - JSON-LD context (optional) + * @param {object} req.user - Authenticated user from JWT token + * @returns {object} Created object with @id and __rerum metadata + */ router.route('/') .post(auth.checkJwt, controller.create) .all((req, res, next) => { diff --git a/routes/delete.js b/routes/delete.js index 7e747ff..74940f1 100644 --- a/routes/delete.js +++ b/routes/delete.js @@ -4,6 +4,15 @@ const router = express.Router() import controller from '../db-controller.js' import auth from '../auth/index.js' +/** + * DELETE /v1/api/delete or DELETE /v1/api/delete/:_id - Delete an object + * Requires JWT authentication + * + * @param {string} [req.params._id] - Optional object ID from URL + * @param {object} req.body - Object containing delete instructions + * @param {object} req.user - Authenticated user from JWT token + * @returns {object} Deleted object metadata or status information + */ router.route('/') .delete(auth.checkJwt, controller.deleteObj) .all((req, res, next) => { diff --git a/routes/id.js b/routes/id.js index 3c2e898..37c3023 100644 --- a/routes/id.js +++ b/routes/id.js @@ -3,6 +3,14 @@ const router = express.Router() //This controller will handle all MongoDB interactions. import controller from '../db-controller.js' +/** + * GET /v1/id/:_id - Retrieve object by ID or slug + * HEAD /v1/id/:_id - Retrieve metadata headers for an object + * Public endpoint, no authentication required + * + * @param {string} req.params._id - Object ID or slug + * @returns {object} Retrieved object or deleted object metadata + */ router.route('/:_id') .get(controller.id) .head(controller.idHeadRequest) diff --git a/routes/query.js b/routes/query.js index 61c33c9..41717ce 100644 --- a/routes/query.js +++ b/routes/query.js @@ -3,6 +3,14 @@ const router = express.Router() //This controller will handle all MongoDB interactions. import controller from '../db-controller.js' +/** + * POST /v1/api/query - Query objects by matching properties + * HEAD /v1/api/query - Query head request for matching objects + * Public endpoint, no authentication required + * + * @param {object} req.body - Query object with properties to match + * @returns {object[]} Array of matching objects + */ router.route('/') .post(controller.query) .head(controller.queryHeadRequest) diff --git a/routes/release.js b/routes/release.js index 870c0d8..2c3b4ff 100644 --- a/routes/release.js +++ b/routes/release.js @@ -5,6 +5,14 @@ const router = express.Router() import controller from '../db-controller.js' import auth from '../auth/index.js' +/** + * PATCH /v1/api/release/:_id - Release an object to make it immutable + * Requires JWT authentication + * + * @param {string} req.params._id - Object ID or slug to release + * @param {object} req.user - Authenticated user from JWT token + * @returns {object} Released object metadata with updated __rerum state + */ router.route('/:_id') .patch(auth.checkJwt, controller.release) .all((req, res, next) => { diff --git a/routes/search.js b/routes/search.js index 2053bf5..a4c95a8 100644 --- a/routes/search.js +++ b/routes/search.js @@ -2,6 +2,14 @@ import express from 'express' const router = express.Router() import controller from '../db-controller.js' +/** + * POST /v1/api/search - Full-text search by words + * Public endpoint, no authentication required + * + * @param {object} req.body - Search query payload + * @param {string} req.body.query - Search terms to match + * @returns {object[]} Array of matching objects + */ router.route('/') .post(controller.searchAsWords) .all((req, res, next) => { @@ -10,6 +18,14 @@ router.route('/') next(res) }) +/** + * POST /v1/api/search/phrase - Full-text search by phrase + * Public endpoint, no authentication required + * + * @param {object} req.body - Search query payload + * @param {string} req.body.query - Exact phrase to match + * @returns {object[]} Array of matching objects + */ router.route('/phrase') .post(controller.searchAsPhrase) .all((req, res, next) => {