An open API service indexing awesome lists of open source software.

https://github.com/sequencemedia/verify-url

Verify URLs in Node with Fetch or SuperAgent
https://github.com/sequencemedia/verify-url

Last synced: 3 months ago
JSON representation

Verify URLs in Node with Fetch or SuperAgent

Awesome Lists containing this project

README

          

# @sequencemedia/verify-url

Verifies that a URL is publicly accessible on the network

## `verifyUrl`

The `verifyUrl` function returns a Promise which resolves to an object

That object is a _description_

- It always contains a `verification` string (either `PASS` or `FAIL`)
- It always contains the `url` string

### 1 - The verification request was successful and the remote host returned a status in the `success` range

The value of `verification` in the description is `PASS`

```typescript
export interface ResponseSuccess {
verification: string;
url: string;
}
```

### 2 - The verification request was successful but the remote host returned a status in the `failure` range

Dispatching a request was fine but the host or the path was not

- Perhaps a `500`
- Perhaps a `404`
- Etc

The value of `verification` in the description is `FAIL`

```typescript
export interface ResponseFailure {
verification: string;
url: string;
response: {status: number};
}
```

### 3 - The verification request failed

Either the `url` was not a valid URL or dispatching a request to it generated an error

- Perhaps the host does not exist
- Perhaps the host is not reachable
- Etc

The value of `verification` in the description is `FAIL`

```typescript
export interface RequestFailure {
verification: string;
url: string;
error: {code: string};
}
```