prismpanel 0.0.3 → 0.0.5
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/package.json
CHANGED
|
@@ -20,6 +20,24 @@ export async function createUser() {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// Connect FIRST before asking questions
|
|
24
|
+
const spinner = ora("Connecting to MongoDB...").start();
|
|
25
|
+
try {
|
|
26
|
+
await mongoose.connect(mongodbUri, {
|
|
27
|
+
connectTimeoutMS: 5000, // Fail faster (5 seconds instead of 30)
|
|
28
|
+
serverSelectionTimeoutMS: 5000,
|
|
29
|
+
});
|
|
30
|
+
spinner.succeed(chalk.green("Connected to MongoDB."));
|
|
31
|
+
} catch (error) {
|
|
32
|
+
spinner.fail(chalk.red("Failed to connect to MongoDB."));
|
|
33
|
+
console.error(chalk.red("\nDetails: " + error.message));
|
|
34
|
+
console.log(chalk.yellow("\nTroubleshooting tips:"));
|
|
35
|
+
console.log(chalk.gray(" 1. Check if your IP is whitelisted in Atlas (Network Access)."));
|
|
36
|
+
console.log(chalk.gray(" 2. Make sure your connection string is correct in config.json."));
|
|
37
|
+
console.log(chalk.gray(" 3. Try using a database name (e.g. ...mongodb.net/prism)."));
|
|
38
|
+
return; // Exit if connection fails
|
|
39
|
+
}
|
|
40
|
+
|
|
23
41
|
const answers = await inquirer.prompt([
|
|
24
42
|
{
|
|
25
43
|
type: "input",
|
|
@@ -36,21 +54,18 @@ export async function createUser() {
|
|
|
36
54
|
},
|
|
37
55
|
]);
|
|
38
56
|
|
|
39
|
-
const
|
|
57
|
+
const saveSpinner = ora("Creating user...").start();
|
|
40
58
|
|
|
41
59
|
try {
|
|
42
|
-
await mongoose.connect(mongodbUri);
|
|
43
|
-
spinner.text = "Creating user...";
|
|
44
|
-
|
|
45
60
|
const newUser = new User({
|
|
46
61
|
name: answers.name,
|
|
47
|
-
password: answers.password,
|
|
62
|
+
password: answers.password,
|
|
48
63
|
});
|
|
49
64
|
|
|
50
65
|
await newUser.save();
|
|
51
|
-
|
|
66
|
+
saveSpinner.succeed(chalk.green(`User '${answers.name}' created successfully.`));
|
|
52
67
|
} catch (error) {
|
|
53
|
-
|
|
68
|
+
saveSpinner.fail(chalk.red("Failed to save user."));
|
|
54
69
|
console.error(chalk.red(error.message));
|
|
55
70
|
} finally {
|
|
56
71
|
await mongoose.disconnect();
|
package/@prism_panel/config.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"bot_token": "your_test_token_here", "test_key": "test_value", "mongodb_uri": "mongodb+srv://<user>:<password>@cluster.mongodb.net/prism?retryWrites=true&w=majority"}
|