360-mock-server 1.2.1 → 1.2.3
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/bin/cli.js +4 -4
- package/lib/server.js +1 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ const readline = require("readline");
|
|
|
9
9
|
const packageJson = require("../package.json");
|
|
10
10
|
|
|
11
11
|
// Helper function for making HTTP requests
|
|
12
|
-
function makeRequest(method, endpoint, data, port = "
|
|
12
|
+
function makeRequest(method, endpoint, data, port = "5050") {
|
|
13
13
|
return new Promise((resolve) => {
|
|
14
14
|
const upperMethod = method.toUpperCase();
|
|
15
15
|
const urlPath = endpoint.startsWith("/") ? endpoint : "/" + endpoint;
|
|
@@ -166,7 +166,7 @@ program
|
|
|
166
166
|
program
|
|
167
167
|
.command("run", { isDefault: true })
|
|
168
168
|
.description("Start server + interactive mode (recommended)")
|
|
169
|
-
.option("-p, --port <port>", "Port number", "
|
|
169
|
+
.option("-p, --port <port>", "Port number", "5050")
|
|
170
170
|
.option("-f, --file <filename>", "Data file name", "mock-data.json")
|
|
171
171
|
.action((options) => {
|
|
172
172
|
const dataFile = path.join(process.cwd(), options.file);
|
|
@@ -192,7 +192,7 @@ program
|
|
|
192
192
|
program
|
|
193
193
|
.command("start")
|
|
194
194
|
.description("Start the mock server only (no interactive mode)")
|
|
195
|
-
.option("-p, --port <port>", "Port number", "
|
|
195
|
+
.option("-p, --port <port>", "Port number", "5050")
|
|
196
196
|
.option("-f, --file <filename>", "Data file name", "mock-data.json")
|
|
197
197
|
.action((options) => {
|
|
198
198
|
const dataFile = path.join(process.cwd(), options.file);
|
|
@@ -266,7 +266,7 @@ program
|
|
|
266
266
|
program
|
|
267
267
|
.command("req <method> <endpoint> [data]")
|
|
268
268
|
.description("Make single API request")
|
|
269
|
-
.option("-p, --port <port>", "Server port", "
|
|
269
|
+
.option("-p, --port <port>", "Server port", "5050")
|
|
270
270
|
.action(async (method, endpoint, data, options) => {
|
|
271
271
|
await makeRequest(method, endpoint, data, options.port);
|
|
272
272
|
});
|
package/lib/server.js
CHANGED
|
@@ -5,7 +5,7 @@ const cors = require("cors");
|
|
|
5
5
|
const { faker } = require("@faker-js/faker");
|
|
6
6
|
|
|
7
7
|
const app = express();
|
|
8
|
-
const PORT = process.env.PORT ||
|
|
8
|
+
const PORT = process.env.PORT || 5050;
|
|
9
9
|
const DATA_FILE = process.env.DATA_FILE || path.join(process.cwd(), "mock-data.json");
|
|
10
10
|
|
|
11
11
|
app.use(cors());
|