| 1 | import { createRequire } from "node:module"; |
| 2 | |
| 3 | // `make-dir` is installed into the artifact by `build.install`, not bundled, |
| 4 | // so it is loaded through a runtime require against the artifact's |
| 5 | // node_modules — exactly what a deployed function does. |
| 6 | const nodeRequire = createRequire(import.meta.url); |
| 7 | |
| 8 | const handler = async () => { |
| 9 | const makeDir = nodeRequire("make-dir") as (path: string) => Promise<string>; |
| 10 | await makeDir("/tmp/alchemy-lockfile-pinning"); |
| 11 | return { |
| 12 | statusCode: 200, |
| 13 | headers: { |
| 14 | "content-type": "application/json", |
| 15 | }, |
| 16 | body: JSON.stringify({ |
| 17 | makeDir: (nodeRequire("make-dir/package.json") as { version: string }) |
| 18 | .version, |
| 19 | semver: (nodeRequire("semver/package.json") as { version: string }) |
| 20 | .version, |
| 21 | }), |
| 22 | }; |
| 23 | }; |
| 24 | |
| 25 | export { handler }; |
| 26 | export default handler; |