ohdear-npm-audit 0.1.2 → 0.1.4
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/dist/handler.js +1 -1
- package/dist/next.js +30 -2
- package/package.json +1 -1
package/dist/handler.js
CHANGED
|
@@ -19,7 +19,7 @@ export function createHealthHandler(manifest, options) {
|
|
|
19
19
|
const envVar = options?.secretEnvVar ?? "OHDEAR_HEALTH_SECRET";
|
|
20
20
|
const headerName = options?.secretHeader ?? "oh-dear-health-check-secret";
|
|
21
21
|
if (!process.env[envVar]) {
|
|
22
|
-
console.warn(`ohdear-npm-audit:
|
|
22
|
+
console.warn(`ohdear-npm-audit: ${envVar} is not set — all health check requests will be rejected with 401.`);
|
|
23
23
|
}
|
|
24
24
|
return async (request) => {
|
|
25
25
|
const secret = request.headers.get(headerName);
|
package/dist/next.js
CHANGED
|
@@ -1,11 +1,39 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
1
|
+
import { resolve, relative, dirname } from "node:path";
|
|
2
2
|
import { writeManifest } from "./generate.js";
|
|
3
|
+
/**
|
|
4
|
+
* Derive the App Router route path from the manifest output path.
|
|
5
|
+
* e.g. "src/app/api/health/deps-manifest.json" → "/api/health"
|
|
6
|
+
*/
|
|
7
|
+
function deriveRoutePath(outputRelative) {
|
|
8
|
+
const dir = dirname(outputRelative);
|
|
9
|
+
const match = dir.match(/(?:src\/)?app(\/.*)/);
|
|
10
|
+
return match ? match[1] : null;
|
|
11
|
+
}
|
|
12
|
+
let didRun = false;
|
|
3
13
|
export function withOhDearHealth(nextConfig, options) {
|
|
14
|
+
if (didRun)
|
|
15
|
+
return nextConfig;
|
|
16
|
+
didRun = true;
|
|
4
17
|
const cwd = process.cwd();
|
|
5
|
-
const
|
|
18
|
+
const outputRelative = options?.output ?? "src/app/api/health/deps-manifest.json";
|
|
19
|
+
const output = resolve(cwd, outputRelative);
|
|
6
20
|
try {
|
|
7
21
|
const manifest = writeManifest(output, cwd);
|
|
8
22
|
console.log(`ohdear-npm-audit: ${Object.keys(manifest).length} packages written → ${output}`);
|
|
23
|
+
const routePath = deriveRoutePath(relative(cwd, output));
|
|
24
|
+
const domain = process.env.VERCEL_PROJECT_PRODUCTION_URL;
|
|
25
|
+
if (routePath && domain) {
|
|
26
|
+
console.log(`ohdear-npm-audit: Oh Dear health URL → https://${domain}${routePath}`);
|
|
27
|
+
}
|
|
28
|
+
else if (routePath) {
|
|
29
|
+
console.log(`ohdear-npm-audit: Oh Dear health URL → https://<your-domain>${routePath}`);
|
|
30
|
+
}
|
|
31
|
+
if (process.env.OHDEAR_HEALTH_SECRET) {
|
|
32
|
+
console.log("ohdear-npm-audit: OHDEAR_HEALTH_SECRET ✓");
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.warn("ohdear-npm-audit: OHDEAR_HEALTH_SECRET is not set — health check will reject all requests.");
|
|
36
|
+
}
|
|
9
37
|
}
|
|
10
38
|
catch (err) {
|
|
11
39
|
console.error("ohdear-npm-audit: failed to generate dependency manifest.");
|