vovk 2.0.0-beta.5 → 2.0.0-beta.7

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 (2) hide show
  1. package/cli/server.cjs +9 -2
  2. package/package.json +1 -1
package/cli/server.cjs CHANGED
@@ -155,9 +155,16 @@ async function startVovkServer(env) {
155
155
 
156
156
  // due to changes at Next.js 14.2.0 we get too many logs, therefore the interval should be changed to fs.watch
157
157
  // Old approach: setInterval(() => void ping(), 1000 * 3);
158
+
159
+ const srcRoot = path.join(__dirname, '../../..', 'src');
158
160
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
159
- for await (const _info of fs.watch(path.join(__dirname, '../../..', 'src'), { recursive: true })) {
160
- void ping();
161
+ for await (const info of fs.watch(srcRoot, { recursive: true })) {
162
+ if (info.filename) {
163
+ const filename = path.join(srcRoot, info.filename);
164
+ const importRegex = /import\s*{[^}]*\b(get|post|put|del|head|options)\b[^}]*}\s*from\s*['"]vovk['"]/;
165
+ const fileContent = await fs.readFile(filename, 'utf-8');
166
+ if (importRegex.test(fileContent)) await ping(); // TODO: Debounce this
167
+ }
161
168
  }
162
169
  }
163
170
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.0-beta.7",
4
4
  "description": "REST for Next - Transforms Next.js into a powerful and extensible REST API platform",
5
5
  "bin": "./cli/index.cjs",
6
6
  "scripts": {