aiiinotate 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,12 +8,14 @@ MONGODB_PORT=27017
8
8
  MONGODB_DB=aiiinotate
9
9
 
10
10
  # HTTP port for the app
11
- APP_PORT=4000
12
- # URL for the app, inclding port
13
- APP_HOST=http://127.0.0.1
11
+ AIIINOTATE_PORT=4000
12
+ # URL for the app
13
+ AIIINOTATE_HOST=127.0.0.1
14
+ # HTTP scheme: HTTP or HTTPS. should be HTTP in dev and in docker
15
+ AIIINOTATE_SCHEME=http
14
16
 
15
17
  # IGNORE
16
- APP_BASE_URL="$APP_HOST:$APP_PORT"
18
+ AIIINOTATE_BASE_URL="$AIIINOTATE_SCHEME://$AIIINOTATE_HOST:$AIIINOTATE_PORT"
17
19
  # IGNORE
18
20
  MONGODB_CONNSTRING="mongodb://$MONGODB_HOST:$MONGODB_PORT/$MONGODB_DB"
19
21
  # IGNORE
package/docker/README.md CHANGED
@@ -58,5 +58,5 @@ sudo docker exec -it docker-web-1 npm list -g --depth=0
58
58
  CURL the Web container
59
59
 
60
60
  ```bash
61
- sudo docker exec -it docker-web-1 curl http://0.0.0.0:4444 # change 4444 by your $APP_PORT
61
+ sudo docker exec -it docker-web-1 curl http://0.0.0.0:4444 # change 4444 by your $AIIINOTATE_PORT
62
62
  ```
@@ -19,11 +19,12 @@ services:
19
19
  context: ..
20
20
  dockerfile: docker/Dockerfile
21
21
  args:
22
- PORT: ${APP_PORT}
22
+ PORT: ${AIIINOTATE_PORT}
23
+ # NOTE: be careful to point to docker/.env, not to config/.env, otherwise you will have very, very annoying errors.
23
24
  env_file:
24
- - ../config/.env
25
+ - ../docker/.env
25
26
  ports:
26
- - "${APP_PORT}:${APP_PORT}"
27
+ - "${AIIINOTATE_PORT}:${AIIINOTATE_PORT}"
27
28
  depends_on:
28
29
  - mongo
29
30
  networks:
package/docker/docker.sh CHANGED
@@ -45,7 +45,7 @@ env_to_docker() {
45
45
  # NOTE that the MongoDB host in Docker MUST BE the name of the Mongo docker service (defined in docker-compose)
46
46
  cp "$ENV_CONFIG" "$ENV_DOCKER";
47
47
  sed_repl s~^MONGODB_HOST=.*$~MONGODB_HOST=mongo~ "$ENV_DOCKER";
48
- sed_repl s~^APP_HOST=.*~APP_HOST=0.0.0.0~ "$ENV_DOCKER";
48
+ sed_repl s~^AIIINOTATE_HOST=.*~AIIINOTATE_HOST=0.0.0.0~ "$ENV_DOCKER";
49
49
  }
50
50
  env_to_docker;
51
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiiinotate",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "a fast IIIF-compliant annotation server",
5
5
  "main": "./cli/index.js",
6
6
  "type": "module",
package/src/app.js CHANGED
@@ -45,7 +45,7 @@ const defaultConfig = {
45
45
  // },
46
46
  // servers: [
47
47
  // {
48
- // url: process.env.APP_BASE_URL,
48
+ // url: process.env.AIIINOTATE_BASE_URL,
49
49
  // description: "Aiiinotate URL"
50
50
  // }
51
51
  // ],
@@ -67,7 +67,7 @@ const defaultConfig = {
67
67
  // // url: 'https://swagger.io',
68
68
  // // description: 'Find more info here'
69
69
  // // },
70
- // // host: process.env.APP_BASE_URL.replace(/^http(s)?\:\/\//g, ""), // process.env.APP_BASE_URL,
70
+ // // host: process.env.AIIINOTATE_BASE_URL.replace(/^http(s)?\:\/\//g, ""), // process.env.AIIINOTATE_BASE_URL,
71
71
  // // schemes: [ "http", "https" ],
72
72
  // // consumes: ['application/json'],
73
73
  // // produces: ['application/json'],
@@ -41,7 +41,7 @@ test("test annotation Routes", async (t) => {
41
41
 
42
42
  // NOTE: it is necessary to run the app because internally there are fetches to external data.
43
43
  try {
44
- await fastify.listen({ port: process.env.APP_PORT, host: process.env.APP_HOST });
44
+ await fastify.listen({ port: process.env.AIIINOTATE_PORT, host: process.env.AIIINOTATE_HOST });
45
45
  } catch (err) {
46
46
  console.log("FASTIFY ERROR", err);
47
47
  throw err;
@@ -158,8 +158,8 @@ test("test annotation Routes", async (t) => {
158
158
  const
159
159
  annotationIdQuery =
160
160
  shouldExist
161
- ? annotationId.replace(process.env.APP_BASE_URL, "")
162
- : annotationId.replace(process.env.APP_BASE_URL, "") + "string_that_does_not_exist_in_the_db",
161
+ ? annotationId.replace(process.env.AIIINOTATE_BASE_URL, "")
162
+ : annotationId.replace(process.env.AIIINOTATE_BASE_URL, "") + "string_that_does_not_exist_in_the_db",
163
163
  r = await fastify.inject({
164
164
  method: "GET",
165
165
  url: annotationIdQuery
@@ -289,7 +289,7 @@ class Manifests2 extends CollectionAbstract {
289
289
  return {
290
290
  ...IIIF_PRESENTATION_2_CONTEXT,
291
291
  "@type": "sc:Collection",
292
- "@id": `${process.env.APP_BASE_URL}/manifests/2`,
292
+ "@id": `${process.env.AIIINOTATE_BASE_URL}/manifests/2`,
293
293
  label: "Collection of all manifests indexed in the annotation server",
294
294
  members: manifestIndex
295
295
  }
@@ -27,7 +27,7 @@ test("test Manifests2 module", async (t) => {
27
27
 
28
28
  // NOTE: it is necessary to run the app because internally there are fetches to external data.
29
29
  try {
30
- await fastify.listen({ port: process.env.APP_PORT, host: process.env.APP_HOST });
30
+ await fastify.listen({ port: process.env.AIIINOTATE_PORT, host: process.env.AIIINOTATE_HOST });
31
31
  } catch (err) {
32
32
  console.log("FASTIFY ERROR", err);
33
33
  throw err;
@@ -30,7 +30,7 @@ test("test manifests Routes", async (t) => {
30
30
 
31
31
  // NOTE: it is necessary to run the app because internally there are fetches to external data.
32
32
  try {
33
- await fastify.listen({ port: process.env.APP_PORT, host: process.env.APP_HOST });
33
+ await fastify.listen({ port: process.env.AIIINOTATE_PORT, host: process.env.AIIINOTATE_HOST });
34
34
  } catch (err) {
35
35
  console.log("FASTIFY ERROR", err);
36
36
  throw err;
@@ -26,7 +26,7 @@ test("test common routes", async (t) => {
26
26
 
27
27
  // NOTE: it is necessary to run the app because internally there are fetches to external data.
28
28
  try {
29
- await fastify.listen({ port: process.env.APP_PORT, host: process.env.APP_HOST });
29
+ await fastify.listen({ port: process.env.AIIINOTATE_PORT, host: process.env.AIIINOTATE_HOST });
30
30
  } catch (err) {
31
31
  console.log("FASTIFY ERROR", err);
32
32
  throw err;
@@ -150,10 +150,10 @@ const makeAnnotationId = (annotation, manifestShortId) => {
150
150
  * @returns {string}
151
151
  */
152
152
  const annotationUri = (manifestShortId, canvasId) =>
153
- `${process.env.APP_BASE_URL}/data/${IIIF_PRESENTATION_2}/${manifestShortId}/annotation/${canvasId}_${uuid4()}`;
153
+ `${process.env.AIIINOTATE_BASE_URL}/data/${IIIF_PRESENTATION_2}/${manifestShortId}/annotation/${canvasId}_${uuid4()}`;
154
154
 
155
155
  const manifestUri = (manifestShortId) =>
156
- `${process.env.APP_BASE_URL}/data/${IIIF_PRESENTATION_2}/${manifestShortId}/manifest.json`;
156
+ `${process.env.AIIINOTATE_BASE_URL}/data/${IIIF_PRESENTATION_2}/${manifestShortId}/manifest.json`;
157
157
 
158
158
  /**
159
159
  * if `canvasUri` follows the recommended IIIF 2.1 recommended URI pattern, convert it to a JSON manifest URI.
@@ -88,7 +88,7 @@ test("test 'iiif2Utils' functions", async (t) => {
88
88
  const escapeRegExp = (string) =>
89
89
  string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
90
90
 
91
- const rgx = new RegExp(`^${escapeRegExp(process.env.APP_BASE_URL)}/data/2/[^(\\s|/)]+/annotation/[^\\.]+$`);
91
+ const rgx = new RegExp(`^${escapeRegExp(process.env.AIIINOTATE_BASE_URL)}/data/2/[^(\\s|/)]+/annotation/[^\\.]+$`);
92
92
  annotations2Valid.map((annotation) =>
93
93
  t.assert.strictEqual(rgx.test(makeAnnotationId(annotation)), true));
94
94
  annotations2Invalid.map((annotation) =>
@@ -135,7 +135,7 @@ const maybeToArray = (x, convertedFlag=false) =>
135
135
  : Array.isArray(x) ? x : [x];
136
136
 
137
137
  const pathToUrl = (path) =>
138
- `${process.env.APP_BASE_URL}${path}`
138
+ `${process.env.AIIINOTATE_BASE_URL}${path}`
139
139
 
140
140
  /**
141
141
  * display a detailed and nested view of an object. to be used with console.log.
@@ -25,7 +25,7 @@ const readFileToObject = (fn) => {
25
25
  * @param {string} fn
26
26
  * @returns {string}
27
27
  */
28
- const toUrl = (fn) => `${process.env.APP_BASE_URL}/fileServer/${fn}`;
28
+ const toUrl = (fn) => `${process.env.AIIINOTATE_BASE_URL}/fileServer/${fn}`;
29
29
 
30
30
 
31
31
  export {
@@ -4,7 +4,7 @@ import fastifyPlugin from "fastify-plugin"
4
4
 
5
5
  /** @param {"search"|"presentation"} slug */
6
6
  const makeSchemaUri = (slug) =>
7
- `${process.env.APP_BASE_URL}/schemas/${slug}/version`;
7
+ `${process.env.AIIINOTATE_BASE_URL}/schemas/${slug}/version`;
8
8
 
9
9
  /**
10
10
  * @param {FastifyInstanceType} fastify
@@ -55,7 +55,7 @@ const embeddedBodyTypeValues = [
55
55
 
56
56
  /** @param {string} slug */
57
57
  const makeSchemaUri = (slug) =>
58
- `${process.env.APP_BASE_URL}/schemas/presentation/${IIIF_PRESENTATION_2}/${slug}`
58
+ `${process.env.AIIINOTATE_BASE_URL}/schemas/presentation/${IIIF_PRESENTATION_2}/${slug}`
59
59
 
60
60
  /**
61
61
  * @param {FastifyInstanceType} fastify
@@ -6,7 +6,7 @@ import { IIIF_PRESENTATION_3, IIIF_PRESENTATION_3_CONTEXT } from "#utils/iiifUti
6
6
 
7
7
  /** @param {string} slug */
8
8
  const makeSchemaUri = (slug) =>
9
- `${process.env.APP_BASE_URL}/schemas/presentation/${IIIF_PRESENTATION_3}/${slug}`
9
+ `${process.env.AIIINOTATE_BASE_URL}/schemas/presentation/${IIIF_PRESENTATION_3}/${slug}`
10
10
 
11
11
  /**
12
12
  * @param {FastifyInstanceType} fastify
@@ -9,7 +9,7 @@ import fastifyPlugin from "fastify-plugin";
9
9
 
10
10
  /** @param {string} slug */
11
11
  const makeSchemaUri = (slug) =>
12
- `${process.env.APP_BASE_URL}/schemas/routes/${slug}`;
12
+ `${process.env.AIIINOTATE_BASE_URL}/schemas/routes/${slug}`;
13
13
 
14
14
  /**
15
15
  * @param {FastifyInstanceType} fastify
package/src/server.js CHANGED
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  import build from "#src/app.js";
6
- import { visibleLog } from "#utils/utils.js";
7
6
 
8
7
  /**
9
8
  * @param {import("#types").RerveModeType} serveMode
@@ -14,13 +13,8 @@ async function server (serveMode) {
14
13
  }
15
14
 
16
15
  const fastify = await build(serveMode);
17
-
18
- visibleLog([process.env.APP_HOST, process.env.APP_PORT], "PRE:");
19
- process.env.APP_HOST = "0.0.0.0";
20
- visibleLog([process.env.APP_HOST, process.env.APP_PORT], "POST:");
21
-
22
16
  try {
23
- fastify.listen({ port: process.env.APP_PORT, host: process.env.APP_HOST });
17
+ fastify.listen({ port: process.env.AIIINOTATE_PORT, host: process.env.AIIINOTATE_HOST });
24
18
  } catch(err) {
25
19
  fastify.log.error(err);
26
20
  process.exit(1);