@prosopo/client-example-server 2.7.15 → 2.7.17

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @prosopo/client-example-server
2
2
 
3
+ ## 2.7.17
4
+ ### Patch Changes
5
+
6
+ - eb71691: configure typecheck before bundle for vue packages
7
+ - eb71691: make typecheck script always recompile
8
+ - Updated dependencies [eb71691]
9
+ - Updated dependencies [eb71691]
10
+ - @prosopo/common@3.1.1
11
+ - @prosopo/dotenv@3.0.6
12
+ - @prosopo/server@2.9.13
13
+ - @prosopo/types@3.0.5
14
+ - @prosopo/util@3.0.4
15
+ - @prosopo/config@3.1.2
16
+
17
+ ## 2.7.16
18
+ ### Patch Changes
19
+
20
+ - 52dbf21: bumping deps
21
+ - 3573f0b: fix npm scripts bundle command
22
+ - 3573f0b: build using vite, typecheck using tsc
23
+ - efd8102: Add tests for unwrap error helper
24
+ - 3573f0b: standardise all vite based npm scripts for bundling
25
+ - Updated dependencies [52dbf21]
26
+ - Updated dependencies [93d5e50]
27
+ - Updated dependencies [3573f0b]
28
+ - Updated dependencies [3573f0b]
29
+ - Updated dependencies [efd8102]
30
+ - Updated dependencies [93d5e50]
31
+ - Updated dependencies [63519d7]
32
+ - Updated dependencies [f29fc7e]
33
+ - Updated dependencies [3573f0b]
34
+ - Updated dependencies [2d0dd8a]
35
+ - @prosopo/util@3.0.3
36
+ - @prosopo/server@2.9.12
37
+ - @prosopo/types@3.0.4
38
+ - @prosopo/common@3.1.0
39
+ - @prosopo/dotenv@3.0.5
40
+ - @prosopo/config@3.1.1
41
+
3
42
  ## 2.7.15
4
43
  ### Patch Changes
5
44
 
package/dist/app.js CHANGED
@@ -1,70 +1,73 @@
1
1
  import path from "node:path";
2
- import { ProsopoEnvError, getLogger } from "@prosopo/common";
2
+ import { getLogger, ProsopoEnvError } from "@prosopo/common";
3
3
  import { loadEnv } from "@prosopo/dotenv";
4
4
  import { getServerConfig } from "@prosopo/server";
5
5
  import { at } from "@prosopo/util";
6
6
  import cors from "cors";
7
7
  import express from "express";
8
- import routesFactory from "./routes/routes.js";
8
+ import getRoutes from "./routes/routes.js";
9
9
  import connectionFactory from "./utils/connection.js";
10
- import memoryServerSetup from "./utils/database.js";
10
+ import { memoryServerSetup } from "./utils/database.js";
11
11
  loadEnv();
12
- export function getEnvFile(filename = ".env", filepath = "./") {
13
- const env = process.env.NODE_ENV || "development";
14
- return path.join(filepath, `${filename}.${env}`);
12
+ function getEnvFile(filename = ".env", filepath = "./") {
13
+ const env = process.env.NODE_ENV || "development";
14
+ return path.join(filepath, `${filename}.${env}`);
15
15
  }
16
- var ProsopoVerificationType;
17
- (function (ProsopoVerificationType) {
18
- ProsopoVerificationType["api"] = "api";
19
- ProsopoVerificationType["local"] = "local";
20
- })(ProsopoVerificationType || (ProsopoVerificationType = {}));
16
+ var ProsopoVerificationType = /* @__PURE__ */ ((ProsopoVerificationType2) => {
17
+ ProsopoVerificationType2["api"] = "api";
18
+ ProsopoVerificationType2["local"] = "local";
19
+ return ProsopoVerificationType2;
20
+ })(ProsopoVerificationType || {});
21
21
  const logger = getLogger("info", import.meta.url);
22
22
  async function main() {
23
- loadEnv();
24
- const apiPrefix = process.env.NODE_ENV && process.env.NODE_ENV === "production"
25
- ? ""
26
- : `${process.env.NODE_ENV}-`;
27
- const verifyEndpoint = process.env.PROSOPO_VERIFY_ENDPOINT ||
28
- `https://${apiPrefix}api.prosopo.io/siteverify`;
29
- const verifyType = Object.keys(ProsopoVerificationType).includes(process.env.PROSOPO_VERIFICATION_TYPE)
30
- ? process.env.PROSOPO_VERIFICATION_TYPE
31
- : ProsopoVerificationType.api;
32
- const app = express();
33
- app.use(cors({ origin: true, credentials: true }));
34
- app.use(express.urlencoded({ extended: true }));
35
- app.use(express.json());
36
- app.use((_, res, next) => {
37
- res.setHeader("Access-Control-Allow-Origin", "*");
38
- res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE");
39
- res.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, X-Auth-Token, Authorization");
40
- next();
23
+ loadEnv();
24
+ const apiPrefix = process.env.NODE_ENV && process.env.NODE_ENV === "production" ? "" : `${process.env.NODE_ENV}-`;
25
+ const verifyEndpoint = process.env.PROSOPO_VERIFY_ENDPOINT || `https://${apiPrefix}api.prosopo.io/siteverify`;
26
+ const verifyType = Object.keys(
27
+ ProsopoVerificationType
28
+ ).includes(process.env.PROSOPO_VERIFICATION_TYPE) ? process.env.PROSOPO_VERIFICATION_TYPE : "api";
29
+ const app = express();
30
+ app.use(cors({ origin: true, credentials: true }));
31
+ app.use(express.urlencoded({ extended: true }));
32
+ app.use(express.json());
33
+ app.use((_, res, next) => {
34
+ res.setHeader("Access-Control-Allow-Origin", "*");
35
+ res.setHeader(
36
+ "Access-Control-Allow-Methods",
37
+ "GET, POST, PUT, PATCH, DELETE"
38
+ );
39
+ res.setHeader(
40
+ "Access-Control-Allow-Headers",
41
+ "Origin, Content-Type, X-Auth-Token, Authorization"
42
+ );
43
+ next();
44
+ });
45
+ app.options("/*", (_, res) => {
46
+ res.sendStatus(200);
47
+ });
48
+ const uri = await memoryServerSetup();
49
+ logger.info(() => ({ msg: "mongo uri", data: { uri } }));
50
+ const mongoose = connectionFactory(uri);
51
+ if (!process.env.PROSOPO_SITE_PRIVATE_KEY) {
52
+ const mnemonicError = new ProsopoEnvError("GENERAL.MNEMONIC_UNDEFINED", {
53
+ context: { missingParams: ["PROSOPO_SITE_PRIVATE_KEY"] },
54
+ logger
41
55
  });
42
- app.options("/*", (_, res) => {
43
- res.sendStatus(200);
44
- });
45
- const uri = await memoryServerSetup();
46
- logger.info(() => ({ msg: "mongo uri", data: { uri } }));
47
- const mongoose = connectionFactory(uri);
48
- if (!process.env.PROSOPO_SITE_PRIVATE_KEY) {
49
- const mnemonicError = new ProsopoEnvError("GENERAL.MNEMONIC_UNDEFINED", {
50
- context: { missingParams: ["PROSOPO_SITE_PRIVATE_KEY"] },
51
- logger,
52
- });
53
- logger.error(() => ({ err: mnemonicError }));
54
- }
55
- const config = getServerConfig();
56
- logger.info(() => ({ msg: "Config", data: { config } }));
57
- app.use(routesFactory(mongoose, config, verifyEndpoint, verifyType));
58
- app.listen(config.serverUrl
59
- ? Number.parseInt(at(config.serverUrl.split(":"), 2))
60
- : 9228);
56
+ logger.error(() => ({ err: mnemonicError }));
57
+ }
58
+ const config = getServerConfig();
59
+ logger.info(() => ({ msg: "Config", data: { config } }));
60
+ app.use(getRoutes(mongoose, config, verifyEndpoint, verifyType));
61
+ app.listen(
62
+ config.serverUrl ? Number.parseInt(at(config.serverUrl.split(":"), 2)) : 9228
63
+ );
61
64
  }
62
- main()
63
- .then(() => {
64
- logger.info(() => ({ msg: "Server started" }));
65
- })
66
- .catch((err) => {
67
- logger.error(() => ({ err }));
68
- process.exit();
65
+ main().then(() => {
66
+ logger.info(() => ({ msg: "Server started" }));
67
+ }).catch((err) => {
68
+ logger.error(() => ({ err }));
69
+ process.exit();
69
70
  });
70
- //# sourceMappingURL=app.js.map
71
+ export {
72
+ getEnvFile
73
+ };