@dainprotocol/service-sdk 1.0.93 → 1.0.94
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.
|
@@ -17,31 +17,42 @@ Object.defineProperty(exports, "MemoryProcessStore", { enumerable: true, get: fu
|
|
|
17
17
|
function defineDAINService(config) {
|
|
18
18
|
const baseService = (0, service_1.createBaseDAINService)(config);
|
|
19
19
|
const startNode = async (options = {
|
|
20
|
-
port:
|
|
20
|
+
port: undefined,
|
|
21
21
|
}) => {
|
|
22
|
-
const { port } = options;
|
|
22
|
+
const { port = process.env.PORT ? parseInt(process.env.PORT) : 2022 } = options;
|
|
23
23
|
const { serve } = await Promise.resolve().then(() => tslib_1.__importStar(require("@hono/node-server")));
|
|
24
24
|
const service = baseService.startService();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (config.serverExtensions) {
|
|
30
|
-
config.serverExtensions.forEach((extension) => {
|
|
31
|
-
extension.connect(service, server);
|
|
25
|
+
try {
|
|
26
|
+
const server = serve({
|
|
27
|
+
fetch: service.fetch,
|
|
28
|
+
port,
|
|
32
29
|
});
|
|
30
|
+
if (config.serverExtensions) {
|
|
31
|
+
config.serverExtensions.forEach((extension) => {
|
|
32
|
+
extension.connect(service, server);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
console.log(`Server is listening on port ${port} -- Node Environment`);
|
|
36
|
+
console.log(`DAIN Service is running on version ${config.metadata.version}`);
|
|
37
|
+
return {
|
|
38
|
+
address: () => ({ port }),
|
|
39
|
+
shutdown: async () => {
|
|
40
|
+
console.log("Shutting down DAIN service...");
|
|
41
|
+
server.close();
|
|
42
|
+
},
|
|
43
|
+
app: service,
|
|
44
|
+
server: server,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof Error && error.message.includes('EADDRINUSE')) {
|
|
49
|
+
const devMessage = process.env.DAIN_DEV
|
|
50
|
+
? `\n\nIn development mode, you can start the service with a different port using:\n\n npm run dev --port ${port + 1}\n`
|
|
51
|
+
: '';
|
|
52
|
+
throw new Error(`EADDRINUSE\n\nPort ${port} is already in use. Please choose a different port or ensure no other service is running on this port.${devMessage}`);
|
|
53
|
+
}
|
|
54
|
+
throw error; // Re-throw other errors
|
|
33
55
|
}
|
|
34
|
-
console.log(`Server is listening on port ${port} -- Node Environment`);
|
|
35
|
-
console.log(`DAIN Service is running on version ${config.metadata.version}`);
|
|
36
|
-
return {
|
|
37
|
-
address: () => ({ port }),
|
|
38
|
-
shutdown: async () => {
|
|
39
|
-
console.log("Shutting down DAIN service...");
|
|
40
|
-
server.close();
|
|
41
|
-
},
|
|
42
|
-
app: service,
|
|
43
|
-
server: server,
|
|
44
|
-
};
|
|
45
56
|
};
|
|
46
57
|
return {
|
|
47
58
|
...baseService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeService.js","sourceRoot":"","sources":["../../src/service/nodeService.ts"],"names":[],"mappings":";;;AAYA,
|
|
1
|
+
{"version":3,"file":"nodeService.js","sourceRoot":"","sources":["../../src/service/nodeService.ts"],"names":[],"mappings":";;;AAYA,8CAyDC;;AApED,uCAAkD;AAClD,iCAMgB;AAgEd,2FArEA,iBAAU,OAqEA;AACV,8FArEA,oBAAa,OAqEA;AACb,8FArEA,oBAAa,OAqEA;AACb,0FArEA,gBAAS,OAqEA;AACT,iGArEA,uBAAgB,OAqEA;AAlElB,2CAAoF;AAmElF,+FAnEO,0BAAc,OAmEP;AACd,kGApEuB,6BAAiB,OAoEvB;AACjB,mGArE0C,8BAAkB,OAqE1C;AAnEpB,SAAgB,iBAAiB,CAAC,MAAyB;IACzD,MAAM,WAAW,GAAG,IAAA,+BAAqB,EAAC,MAAM,CAAC,CAAC;IAElD,MAAM,SAAS,GAAG,KAAK,EACrB,UAA6B;QAC3B,IAAI,EAAE,SAAS;KAChB,EAMA,EAAE;QACH,MAAM,EAAE,IAAI,GAAG,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