fix: mac-oui-lookup ESM/CJS interop crash on startup
Named import of a CommonJS module's export crashed the whole process at boot (SyntaxError, not caught by tsc since it's a runtime module resolution behavior, not a type error). Verified by actually running the built output with node this time instead of trusting tsc alone. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||||
import type Database from "better-sqlite3";
|
import type Database from "better-sqlite3";
|
||||||
import { getVendor } from "mac-oui-lookup";
|
// mac-oui-lookup is CommonJS; Node's ESM interop doesn't reliably expose its
|
||||||
|
// named exports (crashed the whole process on startup with
|
||||||
|
// "Named export 'getVendor' not found" despite working fine under
|
||||||
|
// require()) -- import the default and destructure instead.
|
||||||
|
import macOuiLookup from "mac-oui-lookup";
|
||||||
|
const { getVendor } = macOuiLookup;
|
||||||
import { getRecentDevices, setDeviceLabel, clearDeviceLabel, type DeviceRow } from "../db/index.js";
|
import { getRecentDevices, setDeviceLabel, clearDeviceLabel, type DeviceRow } from "../db/index.js";
|
||||||
|
|
||||||
async function requireAuth(req: FastifyRequest, reply: FastifyReply) {
|
async function requireAuth(req: FastifyRequest, reply: FastifyReply) {
|
||||||
|
|||||||
Reference in New Issue
Block a user