mongossee 1.0.11 → 1.0.13

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.
Files changed (3) hide show
  1. package/api/server.js +53 -0
  2. package/index.js +15 -31
  3. package/package.json +1 -1
package/api/server.js ADDED
@@ -0,0 +1,53 @@
1
+ // File: api/server.js
2
+
3
+ export const config = {
4
+ runtime: 'edge', // Code ko fast banata hai
5
+ };
6
+
7
+ export default async function handler(req) {
8
+ // 1. Sirf POST request accept karein
9
+ if (req.method !== 'POST') {
10
+ return new Response(JSON.stringify({ error: 'Method Not Allowed' }), { status: 405 });
11
+ }
12
+
13
+ try {
14
+ // 2. User ke computer se PROMPT receive karein
15
+ const { prompt } = await req.json();
16
+
17
+ // 3. Vercel ke safe locker se API Key nikalein
18
+ // (Ye key code me nahi likhi hai, ye Vercel settings se aayegi)
19
+ const API_KEY = process.env.GEMINI_API_KEY;
20
+
21
+ if (!API_KEY) {
22
+ return new Response(JSON.stringify({ error: 'Server Error: API Key missing' }), { status: 500 });
23
+ }
24
+
25
+ // 4. Google Gemini API URL
26
+ const googleUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${API_KEY}`;
27
+
28
+ // 5. Naya Prompt Structure banayein
29
+ const finalPrompt = `
30
+ You are an expert developer. Generate a JSON array of files.
31
+ Response format: [{"filename": "string", "code": "string"}]
32
+ User Prompt: "${prompt}"
33
+ `;
34
+
35
+ // 6. Google ko request bhejein
36
+ const googleResponse = await fetch(googleUrl, {
37
+ method: 'POST',
38
+ headers: { 'Content-Type': 'application/json' },
39
+ body: JSON.stringify({ contents: [{ parts: [{ text: finalPrompt }] }] })
40
+ });
41
+
42
+ const data = await googleResponse.json();
43
+
44
+ // 7. Result wapis user ko bhejein
45
+ return new Response(JSON.stringify(data), {
46
+ status: 200,
47
+ headers: { 'Content-Type': 'application/json' }
48
+ });
49
+
50
+ } catch (error) {
51
+ return new Response(JSON.stringify({ error: error.message }), { status: 500 });
52
+ }
53
+ }
package/index.js CHANGED
@@ -1,15 +1,13 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const fs = require('fs'); // Node.js File System
4
4
  const path = require('path'); // Node.js Path module
5
5
  const yargs = require('yargs/yargs');
6
6
  const { hideBin } = require('yargs/helpers');
7
7
 
8
- // ⚠️ Paste your official Google Gemini API key here.
9
- const part1 = "AIzaSyCxR0aATnWVzi";
10
- const part2= "TaM2fojD0l5KLpI5LJK2U";
11
-
12
- const API_KEY = part1 + part2;
8
+ // 👇 IMP: Yahan apni Vercel App ka link daalna hoga (Deploy karne ke baad milega)
9
+ // Filhal ye placeholder rakhein, baad me edit karke update kar dena.
10
+ const SERVER_URL = "https://mongossee.vercel.app/api/server";
13
11
 
14
12
 
15
13
  /**
@@ -18,40 +16,29 @@ const API_KEY = part1 + part2;
18
16
  * @param {string} directoryName - The name of the folder to create the project in.
19
17
  */
20
18
  async function generateProject(prompt, directoryName) {
21
- const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${API_KEY}`;
22
-
23
- // --- This is the new, "smarter" prompt ---
24
- // We are asking the AI to act as a file structure generator
25
- // and return a specific JSON format.
26
- const newPrompt = `
27
- You are an expert software developer and project scaffolder.
28
- Based on the user's prompt, generate a complete file structure as a JSON array.
29
- Each object in the array must have two keys:
30
- 1. "filename": (string) The full relative path for the file (e.g., "index.html", "src/styles.css", "js/app.js").
31
- 2. "code": (string) The complete code for that file.
32
-
33
- Only return the raw JSON array, with no other text, explanations, or markdown fences.
34
-
35
- User Prompt: "${prompt}"
36
- `;
19
+
20
+ // ⚠️ CHANGE 3: Hum ab Google ko nahi, apne Server ko call kar rahe hain
21
+ // Note: 'newPrompt' wala logic ab Server (api/server.js) ke paas hai,
22
+ // isliye yahan se hata diya taki code simple rahe.
37
23
 
38
24
  const body = {
39
- contents: [{ parts: [{ text: newPrompt }] }]
25
+ prompt: prompt // Sirf user ka prompt bhej rahe hain
40
26
  };
41
27
 
42
28
  try {
43
29
  console.log(`Code Running in Expresss`);
44
30
 
45
- const response = await fetch(url, {
31
+ const response = await fetch(SERVER_URL, {
46
32
  method: 'POST',
47
33
  headers: { 'Content-Type': 'application/json' },
48
34
  body: JSON.stringify(body),
49
35
  });
50
36
 
51
37
  if (!response.ok) {
52
- const errorData = await response.json();
53
- console.error('❌ API Error Details:', JSON.stringify(errorData.error, null, 2));
54
- throw new Error(`API request failed with status ${response.status}`);
38
+ // Agar server down hai ya error hai
39
+ const errorText = await response.text();
40
+ console.error('❌ Server Error:', response.status, errorText);
41
+ throw new Error(`Server request failed with status ${response.status}`);
55
42
  }
56
43
 
57
44
  const data = await response.json();
@@ -120,10 +107,7 @@ yargs(hideBin(process.argv))
120
107
  });
121
108
  },
122
109
  (argv) => {
123
- if (!API_KEY || API_KEY === "YOUR_GEMINI_API_KEY_HERE") {
124
- console.error('❌ ERROR: Please add your API key to the index.js file.');
125
- return;
126
- }
110
+
127
111
  generateProject(argv.prompt, argv.directory);
128
112
  }
129
113
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongossee",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {