@sgftech/medusa-plugin-marketplace-v2 0.1.28 → 0.1.29
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/index.js +47 -43
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
const express = require("express")
|
|
2
|
-
const { GracefulShutdownServer } = require("medusa-core-utils")
|
|
1
|
+
const express = require("express");
|
|
2
|
+
const { GracefulShutdownServer } = require("medusa-core-utils");
|
|
3
3
|
|
|
4
|
-
const loaders = require("@medusajs/medusa/dist/loaders/index").default
|
|
4
|
+
const loaders = require("@medusajs/medusa/dist/loaders/index").default;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
(async () => {
|
|
7
|
+
async function start() {
|
|
8
|
+
const app = express();
|
|
9
|
+
const directory = process.cwd();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
try {
|
|
12
|
+
const { container } = await loaders({
|
|
13
|
+
directory,
|
|
14
|
+
expressApp: app
|
|
15
|
+
});
|
|
16
|
+
const configModule = container.resolve("configModule");
|
|
17
|
+
const port =
|
|
18
|
+
process.env.PORT ?? configModule.projectConfig.port ?? 9000;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const server = GracefulShutdownServer.create(
|
|
21
|
+
app.listen(port, (err) => {
|
|
22
|
+
if (err) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log(`Server is ready on port: ${port}`);
|
|
26
|
+
})
|
|
27
|
+
);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
// Handle graceful shutdown
|
|
30
|
+
const gracefulShutDown = () => {
|
|
31
|
+
server
|
|
32
|
+
.shutdown()
|
|
33
|
+
.then(() => {
|
|
34
|
+
console.info("Gracefully stopping the server.");
|
|
35
|
+
process.exit(0);
|
|
36
|
+
})
|
|
37
|
+
.catch((e) => {
|
|
38
|
+
console.error(
|
|
39
|
+
"Error received when shutting down the server.",
|
|
40
|
+
e
|
|
41
|
+
);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
process.on("SIGTERM", gracefulShutDown);
|
|
46
|
+
process.on("SIGINT", gracefulShutDown);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error("Error starting server", err);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
|
-
}
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
})()
|
|
53
|
+
await start();
|
|
54
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sgftech/medusa-plugin-marketplace-v2",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "0.1.29",
|
|
4
|
+
"description": "A plugin to initiate marketplace",
|
|
5
5
|
"author": "Govind Diwakar",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"headless",
|
|
13
13
|
"medusa",
|
|
14
14
|
"marketplace",
|
|
15
|
-
"
|
|
15
|
+
"workflow"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"clean": "cross-env ./node_modules/.bin/rimraf dist",
|
|
@@ -102,4 +102,4 @@
|
|
|
102
102
|
"coverageDirectory": "./coverage",
|
|
103
103
|
"testEnvironment": "node"
|
|
104
104
|
}
|
|
105
|
-
}
|
|
105
|
+
}
|