# core/adapters/search.adapter.ts

> 16 lines of code and 6 definitions.

Tree: Bane's Lab Deploy
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/deploy#file-deploy-core-adapters-search-adapter-ts
Source text: https://banes-lab.com/source/deploy/core/adapters/search.adapter.ts.txt

Listed in [core/adapters](https://banes-lab.com/api/source/deploy/core/adapters.md), after [core/adapters/release.adapter.ts](https://banes-lab.com/source/deploy/core/adapters/release.adapter.ts.md) and before [core/adapters/server.adapter.ts](https://banes-lab.com/source/deploy/core/adapters/server.adapter.ts.md).

## Definitions

- `CONTENT_TYPE` (lexical_declaration, line 3)
- `JSON_TYPE` (lexical_declaration, line 4)
- `METHOD` (lexical_declaration, line 5)
- `readLive` (lexical_declaration, line 7, exported)
- `postPing` (lexical_declaration, line 12, exported)
- `response` (lexical_declaration, line 13, exported)

## Contained in

- [core/adapters](https://banes-lab.com/anatomy/deploy/folder-deploy-core-adapters.md)

## Source

```typescript
import type { SearchPing } from "#types/deployment.types";

const CONTENT_TYPE = "Content-Type";
const JSON_TYPE = "application/json; charset=utf-8";
const METHOD = "POST";

export const readLive = async function readLive(url: string): Promise<string | null> {
    const response = await fetch(url);
    return response.ok ? response.text() : null;
};

export const postPing = async function postPing(endpoint: string, ping: SearchPing): Promise<number> {
    const response = await fetch(endpoint, {
        body: JSON.stringify(ping),
        headers: { [CONTENT_TYPE]: JSON_TYPE },
        method: METHOD,
    });
    return response.status;
};
```
