@opengis/fastify-table 2.0.12 → 2.0.13

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.
@@ -65,6 +65,7 @@ function plugin(fastify) {
65
65
  };
66
66
  req.user = req.session.passport.user;
67
67
  }
68
+ // ! intentional: null || undefined > undefined
68
69
  req.user = req.user || req.session?.passport?.user || undefined; // fix for user.uid errors, by default user is null, while with express passport it was {}, unauthorized user does not trigger serializer
69
70
  if (config.trace && false) {
70
71
  console.log("req.user?.uid", req.user?.uid, "req.session?.passport?.user?.uid", req.session?.passport?.user?.uid, "config.auth", config.auth);
@@ -9,7 +9,7 @@ import yml2json from "../../yml/funcs/yml2json.js";
9
9
  const cwd = process.cwd();
10
10
  export default function getTemplatePath(type) {
11
11
  if (!type)
12
- return null;
12
+ return [];
13
13
  // form cache
14
14
  if (loadTemplatePath[type])
15
15
  return loadTemplatePath[type];
@@ -1,15 +1,14 @@
1
1
  import fs from "node:fs";
2
- import path from "node:path";
3
- import config from "../../../../config.js";
4
- const loadTemplate = {};
5
- export default async function getTemplateDir(type) {
2
+ import getTemplatePath from "./getTemplatePath.js";
3
+ import loadTemplate from "./loadTemplate.js";
4
+ export default function getTemplateDir(type) {
6
5
  if (!type)
7
6
  return null;
8
- const cwd = process.cwd();
9
- const typeDir = path.join(cwd, config.templateDir || "server/templates", type);
7
+ const arr = Array.isArray(type)
8
+ ? type.map((el) => getTemplatePath(el)).flat()
9
+ : getTemplatePath(type);
10
10
  if (!loadTemplate[type]) {
11
- const typeList = fs.existsSync(typeDir) ? fs.readdirSync(typeDir) : [];
12
- loadTemplate[type] = typeList;
11
+ loadTemplate[type] = arr.filter((el) => fs.existsSync(el[1]));
13
12
  }
14
13
  return loadTemplate[type];
15
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [