@prosopo/client-example-server 2.7.14 → 2.7.16

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,35 @@
1
1
  # @prosopo/client-example-server
2
2
 
3
+ ## 2.7.16
4
+ ### Patch Changes
5
+
6
+ - 52dbf21: bumping deps
7
+ - 3573f0b: fix npm scripts bundle command
8
+ - 3573f0b: build using vite, typecheck using tsc
9
+ - efd8102: Add tests for unwrap error helper
10
+ - 3573f0b: standardise all vite based npm scripts for bundling
11
+ - Updated dependencies [52dbf21]
12
+ - Updated dependencies [93d5e50]
13
+ - Updated dependencies [3573f0b]
14
+ - Updated dependencies [3573f0b]
15
+ - Updated dependencies [efd8102]
16
+ - Updated dependencies [93d5e50]
17
+ - Updated dependencies [63519d7]
18
+ - Updated dependencies [f29fc7e]
19
+ - Updated dependencies [3573f0b]
20
+ - Updated dependencies [2d0dd8a]
21
+ - @prosopo/util@3.0.3
22
+ - @prosopo/server@2.9.12
23
+ - @prosopo/types@3.0.4
24
+ - @prosopo/common@3.1.0
25
+ - @prosopo/dotenv@3.0.5
26
+ - @prosopo/config@3.1.1
27
+
28
+ ## 2.7.15
29
+ ### Patch Changes
30
+
31
+ - @prosopo/server@2.9.11
32
+
3
33
  ## 2.7.14
4
34
  ### Patch Changes
5
35
 
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
+ };