-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd2a9fc
commit 8b7433b
Showing
9 changed files
with
519 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Source: collection-api/routes/services.js</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Source: collection-api/routes/services.js</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article> | ||
<pre class="prettyprint source linenums"><code>import express from 'express'; | ||
|
||
import * as Services from '../../archivist/services/index.js'; | ||
|
||
const services = await Services.load(); | ||
|
||
/** | ||
* @swagger | ||
* tags: | ||
* name: Services | ||
* description: Services API | ||
* components: | ||
* schemas: | ||
* Service: | ||
* type: object | ||
* description: Definition of a service and the agreements its provider sets forth. While the information is the same, the format differs from the JSON declaration files that are designed for readability by contributors. | ||
* properties: | ||
* id: | ||
* type: string | ||
* description: The ID of the service. | ||
* name: | ||
* type: string | ||
* description: The name of the service. | ||
* terms: | ||
* type: array | ||
* description: Information that enables tracking the content of agreements defined by the service provider. | ||
* items: | ||
* type: object | ||
* properties: | ||
* type: | ||
* type: string | ||
* description: The type of terms. | ||
* sourceDocuments: | ||
* type: array | ||
* items: | ||
* type: object | ||
* properties: | ||
* location: | ||
* type: string | ||
* format: uri | ||
* description: The URL of the source document. | ||
* executeClientScripts: | ||
* type: boolean | ||
* description: Whether client-side scripts should be executed. | ||
* contentSelectors: | ||
* type: string | ||
* description: The CSS selectors for selecting significant content. | ||
* insignificantContentSelectors: | ||
* type: string | ||
* description: The CSS selectors for selecting insignificant content. | ||
* filters: | ||
* type: array | ||
* description: The names of filters to apply to the content. | ||
* items: | ||
* type: string | ||
*/ | ||
const router = express.Router(); | ||
|
||
/** | ||
* @swagger | ||
* /services: | ||
* get: | ||
* summary: Enumerate all services. | ||
* tags: [Services] | ||
* produces: | ||
* - application/json | ||
* responses: | ||
* 200: | ||
* description: A JSON array of all services. | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: array | ||
* items: | ||
* type: object | ||
* properties: | ||
* id: | ||
* type: string | ||
* description: The ID of the service. | ||
* name: | ||
* type: string | ||
* description: The name of the service. | ||
* terms: | ||
* type: array | ||
* description: The declared terms types for this service. | ||
* items: | ||
* type: object | ||
* properties: | ||
* type: | ||
* type: string | ||
* description: The type of terms. | ||
*/ | ||
router.get('/services', (req, res) => { | ||
res.status(200).json(Object.values(services).map(service => ({ | ||
id: service.id, | ||
name: service.name, | ||
terms: service.getTermsTypes().map(type => ({ type })), | ||
}))); | ||
}); | ||
|
||
/** | ||
* @swagger | ||
* /service/{serviceId}: | ||
* get: | ||
* summary: Retrieve the declaration of a specific service through its ID. | ||
* tags: [Services] | ||
* produces: | ||
* - application/json | ||
* parameters: | ||
* - in: path | ||
* name: serviceId | ||
* description: The ID of the service. | ||
* schema: | ||
* type: string | ||
* required: true | ||
* examples: | ||
* service-1: | ||
* value: service-1 | ||
* summary: Simple service ID | ||
* service-2: | ||
* value: Service 2! | ||
* summary: Service ID with spaces and special characters | ||
* responses: | ||
* 200: | ||
* description: The full JSON declaration of the service with the given ID. | ||
* content: | ||
* application/json: | ||
* schema: | ||
* $ref: '#/components/schemas/Service' | ||
* 404: | ||
* description: No service matching the provided ID is found. | ||
*/ | ||
router.get('/service/:serviceId', (req, res) => { | ||
const matchedServiceID = Object.keys(services).find(key => key.toLowerCase() === req.params.serviceId?.toLowerCase()); | ||
const service = services[matchedServiceID]; | ||
|
||
if (!service) { | ||
res.status(404).send('Service not found'); | ||
|
||
return; | ||
} | ||
|
||
res.status(200).json({ | ||
id: service.id, | ||
name: service.name, | ||
terms: service.getTerms().map(terms => ({ | ||
type: terms.type, | ||
sourceDocuments: terms.sourceDocuments.map(({ location, contentSelectors, insignificantContentSelectors, filters, executeClientScripts }) => ({ | ||
location, | ||
contentSelectors, | ||
insignificantContentSelectors, | ||
executeClientScripts, | ||
filters: filters?.map(filter => filter.name), | ||
})), | ||
})), | ||
}); | ||
}); | ||
|
||
export default router; | ||
</code></pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Record.html">Record</a></li></ul><h3>Global</h3><ul><li><a href="global.html#extract">extract</a></li><li><a href="global.html#fetch">fetch</a></li><li><a href="global.html#router">router</a></li></ul> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Wed May 22 2024 10:02:48 GMT+0000 (Coordinated Universal Time) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
Oops, something went wrong.