This val default exports a function returning ValInfo.

The val information comes from the Deno stack trace induced by throw new Error().

type ValInfo = {
  stack: string[]; // mostly for debugging
  endpoint: string; // val endpoint URL, empty if it is not an HTTP val
  user: string; // val.town user name
  name: string; // val name
};

Here is an example program:

import thisval from "https://esm.town/v/begoon/thisval";
const val = thisval();
export default async function(req: Request): Promise<Response> {
  return Response.json(val);
}

when invoked, it returns:

{
  "stack": [
    "Error",
    "    at info (https://esm.town/v/begoon/thisval?v=12:10:11)",
    "    at https://esm.town/v/begoon/thisvaltest?v=2:3:13"
  ],
  "endpoint": "begoon-thisvaltest.web.val.run",
  "user": "begoon",
  "name": "thisvaltest"
}