2022-11-24 07:20:30 +00:00
|
|
|
<a name="module_server"></a>
|
2022-11-21 17:30:34 +00:00
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
## server
|
2022-11-22 19:08:28 +00:00
|
|
|
thread-keeper
|
2022-11-21 17:30:34 +00:00
|
|
|
|
|
|
|
**Author**: The Harvard Library Innovation Lab
|
|
|
|
**License**: MIT
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
* [server](#module_server)
|
|
|
|
* _static_
|
|
|
|
* [.successLog](#module_server.successLog) : <code>SuccessLog</code>
|
|
|
|
* [.CAPTURES_WATCH](#module_server.CAPTURES_WATCH) : <code>Object</code>
|
|
|
|
* _inner_
|
|
|
|
* [~accessKeys](#module_server..accessKeys) : <code>AccessKeys</code>
|
|
|
|
* [~index(request, reply)](#module_server..index) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
|
|
|
* [~capture(request, reply)](#module_server..capture) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
|
|
|
* [~check(request, reply)](#module_server..check) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
|
|
|
* [~checkHash(request, reply)](#module_server..checkHash) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
2022-11-21 17:30:34 +00:00
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
<a name="module_server.successLog"></a>
|
2022-11-21 17:30:34 +00:00
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
### server.successLog : <code>SuccessLog</code>
|
|
|
|
**Kind**: static constant of [<code>server</code>](#module_server)
|
|
|
|
<a name="module_server.CAPTURES_WATCH"></a>
|
2022-11-21 17:30:34 +00:00
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
### server.CAPTURES\_WATCH : <code>Object</code>
|
2022-11-21 17:30:34 +00:00
|
|
|
Keeps track of how many capture processes are currently running.
|
|
|
|
May be used to redirect users if over capacity.
|
|
|
|
|
|
|
|
[!] Only good for early prototyping.
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
**Kind**: static constant of [<code>server</code>](#module_server)
|
|
|
|
<a name="module_server..accessKeys"></a>
|
|
|
|
|
|
|
|
### server~accessKeys : <code>AccessKeys</code>
|
|
|
|
**Kind**: inner constant of [<code>server</code>](#module_server)
|
|
|
|
<a name="module_server..index"></a>
|
2022-11-21 17:30:34 +00:00
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
### server~index(request, reply) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
|
|
|
[GET] /
|
|
|
|
Shows the landing page and capture form.
|
2022-11-21 17:30:34 +00:00
|
|
|
Assumes `fastify` is in scope.
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
**Kind**: inner method of [<code>server</code>](#module_server)
|
2022-11-21 17:30:34 +00:00
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| --- | --- |
|
|
|
|
| request | <code>fastify.FastifyRequest</code> |
|
|
|
|
| reply | <code>fastify.FastifyReply</code> |
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
<a name="module_server..capture"></a>
|
|
|
|
|
|
|
|
### server~capture(request, reply) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
|
|
|
[POST] `/`
|
|
|
|
Processes a request to capture a `twitter.com` url.
|
|
|
|
Serves PDF bytes directly if operation is successful.
|
|
|
|
Returns to form with specific error code, passed as `errorReason`, otherwise.
|
|
|
|
Subject to captures rate limiting (see `CAPTURES_WATCH`).
|
|
|
|
|
|
|
|
Body is expected as `application/x-www-form-urlencoded` with the following fields:
|
|
|
|
- access-key
|
|
|
|
- url
|
|
|
|
- unfold-thread (optional)
|
2022-11-22 19:08:28 +00:00
|
|
|
|
|
|
|
Assumes `fastify` is in scope.
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
**Kind**: inner method of [<code>server</code>](#module_server)
|
2022-11-22 19:08:28 +00:00
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| --- | --- |
|
|
|
|
| request | <code>fastify.FastifyRequest</code> |
|
|
|
|
| reply | <code>fastify.FastifyReply</code> |
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
<a name="module_server..check"></a>
|
2022-11-21 17:30:34 +00:00
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
### server~check(request, reply) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
|
|
|
[GET] /check
|
|
|
|
Shows the "check" page /check form. Loads certificates history files in the process.
|
2022-11-21 17:30:34 +00:00
|
|
|
Assumes `fastify` is in scope.
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
**Kind**: inner method of [<code>server</code>](#module_server)
|
2022-11-21 17:30:34 +00:00
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| --- | --- |
|
|
|
|
| request | <code>fastify.FastifyRequest</code> |
|
|
|
|
| reply | <code>fastify.FastifyReply</code> |
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
<a name="module_server..checkHash"></a>
|
2022-11-21 17:30:34 +00:00
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
### server~checkHash(request, reply) ⇒ <code>Promise.<fastify.FastifyReply></code>
|
2022-11-21 17:30:34 +00:00
|
|
|
[GET] `/api/v1/hashes/check/<sha512-hash>`.
|
|
|
|
Checks if a given SHA512 hash is in the "success" logs, meaning this app created it.
|
|
|
|
Hash is passed as the last parameter, url encoded.
|
|
|
|
Assumes `fastify` is in scope.
|
|
|
|
|
|
|
|
Returns HTTP 200 if found, HTTP 404 if not.
|
|
|
|
|
2022-11-24 07:20:30 +00:00
|
|
|
**Kind**: inner method of [<code>server</code>](#module_server)
|
2022-11-21 17:30:34 +00:00
|
|
|
|
|
|
|
| Param | Type |
|
|
|
|
| --- | --- |
|
|
|
|
| request | <code>fastify.FastifyRequest</code> |
|
|
|
|
| reply | <code>fastify.FastifyReply</code> |
|
|
|
|
|