@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 +30 -0
- package/dist/app.js +59 -56
- package/dist/bundle/prosopo_client_example_server.app.bundle.js +13158 -12864
- package/dist/cjs/app.cjs +73 -0
- package/dist/cjs/controllers/auth.cjs +155 -0
- package/dist/cjs/models/user.cjs +23 -0
- package/dist/cjs/routes/routes.cjs +23 -0
- package/dist/cjs/utils/connection.cjs +15 -0
- package/dist/cjs/utils/database.cjs +10 -0
- package/dist/controllers/auth.js +131 -129
- package/dist/models/user.js +21 -20
- package/dist/routes/routes.js +20 -13
- package/dist/utils/connection.js +12 -11
- package/dist/utils/database.js +8 -6
- package/package.json +22 -13
- package/vite.cjs.config.ts +23 -0
- package/vite.esm.config.ts +24 -0
- package/dist/app.d.ts +0 -2
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js.map +0 -1
- package/dist/controllers/auth.d.ts +0 -8
- package/dist/controllers/auth.d.ts.map +0 -1
- package/dist/controllers/auth.js.map +0 -1
- package/dist/models/user.d.ts +0 -19
- package/dist/models/user.d.ts.map +0 -1
- package/dist/models/user.js.map +0 -1
- package/dist/routes/routes.d.ts +0 -6
- package/dist/routes/routes.d.ts.map +0 -1
- package/dist/routes/routes.js.map +0 -1
- package/dist/utils/connection.d.ts +0 -4
- package/dist/utils/connection.d.ts.map +0 -1
- package/dist/utils/connection.js.map +0 -1
- package/dist/utils/database.d.ts +0 -3
- package/dist/utils/database.d.ts.map +0 -1
- package/dist/utils/database.js.map +0 -1
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 {
|
|
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
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})(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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
})
|
|
66
|
-
|
|
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
|
-
|
|
71
|
+
export {
|
|
72
|
+
getEnvFile
|
|
73
|
+
};
|