mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 04:22:01 +00:00
Moves the type file out of the cli package and into its own standalone package. utilizes `@vercel/style-guide` too for typescript config, eslint, and prettier.
24 lines
586 B
TypeScript
24 lines
586 B
TypeScript
import Client from '../client';
|
|
import { Project } from '@vercel-internals/types';
|
|
import { isAPIError, ProjectNotFound } from '../errors-ts';
|
|
|
|
export default async function getProjectByNameOrId(
|
|
client: Client,
|
|
projectNameOrId: string,
|
|
accountId?: string
|
|
) {
|
|
try {
|
|
const project = await client.fetch<Project>(
|
|
`/v8/projects/${encodeURIComponent(projectNameOrId)}`,
|
|
{ accountId }
|
|
);
|
|
return project;
|
|
} catch (err: unknown) {
|
|
if (isAPIError(err) && err.status === 404) {
|
|
return new ProjectNotFound(projectNameOrId);
|
|
}
|
|
|
|
throw err;
|
|
}
|
|
}
|