# core/steps/search.step.ts

> 32 lines of code and 4 definitions.

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

Listed in [core/steps](https://banes-lab.com/api/source/deploy/core/steps.md), after [core/steps/remote.step.ts](https://banes-lab.com/source/deploy/core/steps/remote.step.ts.md) and before [core/steps/setup.step.ts](https://banes-lab.com/source/deploy/core/steps/setup.step.ts.md).

## Definitions

- `pingSearch` (lexical_declaration, line 10, exported)
- `SLASH` (lexical_declaration, line 8)
- `urlList` (lexical_declaration, line 18, exported)
- `status` (lexical_declaration, line 23, exported)

## Contained in

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

## Uses

- [configuration/strings/deployment.strings.ts](https://banes-lab.com/source/deploy/configuration/strings/deployment.strings.ts.md)

## Used by

- [runtime/entrypoints/deployment.entrypoint.ts](https://banes-lab.com/source/deploy/runtime/entrypoints/deployment.entrypoint.ts.md)

## Linked from

- [configuration/strings](https://banes-lab.com/anatomy/deploy/folder-deploy-configuration-strings.md)
- [runtime/entrypoints](https://banes-lab.com/anatomy/deploy/folder-deploy-runtime-entrypoints.md)

## Source

```typescript
import type { Journal, PingPoster, SearchSitemaps } from "#types/deployment.types";
import { PINGING_SEARCH, PING_SKIPPED, pingAccepted, pingRefused } from "#configuration/strings/deployment.strings";
import { SEARCH_PING_ACCEPTED, SEARCH_PING_ENDPOINT } from "#configuration/constants/deployment.constants";
import { SEARCH_KEY_FILE } from "@banes-lab/build-scripts/configuration/constants/site.constants.ts";
import { changedLocations } from "#core/converters/search.converter";
import { postPing } from "#core/adapters/search.adapter";

const SLASH = "/";

export const pingSearch = async function pingSearch(
    journal: Journal,
    site: string,
    key: string,
    sitemaps: SearchSitemaps,
    post: PingPoster = postPing,
): Promise<number> {
    journal.log(PINGING_SEARCH);
    const urlList = changedLocations(sitemaps.before, sitemaps.after);
    if (urlList.length === 0) {
        journal.mark(PING_SKIPPED);
        return 0;
    }
    const status = await post(SEARCH_PING_ENDPOINT, {
        host: new URL(site).host,
        key,
        keyLocation: site + SLASH + SEARCH_KEY_FILE,
        urlList,
    });
    if (!SEARCH_PING_ACCEPTED.has(status)) {
        throw new Error(pingRefused(status));
    }
    journal.mark(pingAccepted(urlList.length));
    return urlList.length;
};
```
