@aztec/aztec-node 0.0.0-test.0

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.
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env -S node --no-warnings
2
+ import { createLogger } from '@aztec/foundation/log';
3
+
4
+ import http from 'http';
5
+
6
+ import { type AztecNodeConfig, AztecNodeService, createAztecNodeRpcServer, getConfigEnvVars } from '../index.js';
7
+
8
+ const { AZTEC_NODE_PORT = 8081, API_PREFIX = '' } = process.env;
9
+
10
+ const logger = createLogger('node');
11
+
12
+ /**
13
+ * Creates the node from provided config
14
+ */
15
+ async function createAndDeployAztecNode() {
16
+ const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars() };
17
+
18
+ return await AztecNodeService.createAndSync(aztecNodeConfig);
19
+ }
20
+
21
+ /**
22
+ * Create and start a new Aztec Node HTTP Server
23
+ */
24
+ async function main() {
25
+ logger.info(`Setting up Aztec Node...`);
26
+
27
+ const aztecNode = await createAndDeployAztecNode();
28
+
29
+ const shutdown = async () => {
30
+ logger.info('Shutting down...');
31
+ await aztecNode.stop();
32
+ process.exit(0);
33
+ };
34
+
35
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
36
+ process.once('SIGINT', shutdown);
37
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
38
+ process.once('SIGTERM', shutdown);
39
+
40
+ const rpcServer = createAztecNodeRpcServer(aztecNode);
41
+ const app = rpcServer.getApp(API_PREFIX);
42
+
43
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
44
+ const httpServer = http.createServer(app.callback());
45
+ httpServer.listen(+AZTEC_NODE_PORT);
46
+ logger.info(`Aztec Node JSON-RPC Server listening on port ${AZTEC_NODE_PORT}`);
47
+ }
48
+
49
+ main().catch(err => {
50
+ logger.error(err);
51
+ process.exit(1);
52
+ });
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './aztec-node/config.js';
2
+ export * from './aztec-node/server.js';
3
+ export * from './aztec-node/http_rpc_server.js';