|
| 1 | +# Checkly |
| 2 | + |
| 3 | +- refer to docs for checkly cli v5 |
| 4 | +- to generate the initial setup for checkly use the command `npm create checkly@latest` |
| 5 | +- check the checkly cli output to figure out into which folder the setup was generated |
| 6 | +- use the [checkly cli reference](https://www.checklyhq.com/docs/cli/command-line-reference) |
| 7 | +- use the [checkly test api](https://www.checklyhq.com/docs/cli/constructs-reference) |
| 8 | +- always ground generated code and cli commands against the official documentation |
| 9 | +- when referencing environment variables always use the handlebar syntax `{{MY_ENV_VAR}}` |
| 10 | +- when referencing secrets always use the handlebar syntax `{{MY_SECRET}}` |
| 11 | +- after the initial setup is done ask the user for which endpoints to generate api checks |
| 12 | +- check in the code if api endpoints require authentication |
| 13 | +- if endpoints require authentication ask the user which authentication method to use and then generate a setupScript to authenticate the given requests |
| 14 | +- referenced setupScript for ApiChecks must be plain ts files and not export anything |
| 15 | + |
| 16 | +## Project Structure |
| 17 | + |
| 18 | +checkly.config.ts - Mandatory global project and CLI configuration. We recommend using TypeScript. |
| 19 | +src/__checks__/* - TS/JS files defining your checks and other resources. |
| 20 | +package.json - Standard NPM project manifest. |
| 21 | +Here is an example directory tree of what that would look like: |
| 22 | + |
| 23 | +. |
| 24 | +|-- checkly.config.ts |
| 25 | +|-- package.json |
| 26 | +`-- src |
| 27 | + `-- __checks__ |
| 28 | + |-- alert-channels.ts |
| 29 | + |-- api-check.check.ts |
| 30 | + `-- homepage.spec.ts |
| 31 | + |
| 32 | +The checkly.config.ts at the root of your project defines a range of defaults for all your checks. |
| 33 | +## `ApiCheck` |
| 34 | + |
| 35 | +- Checkout the api docs for [API Checks](https://www.checklyhq.com/docs/cli/constructs-reference/#apicheck) before generating any code. |
| 36 | +- Only use assertions for Api Checks which are [documented](https://www.checklyhq.com/docs/cli/constructs-reference/#assertionbuilder) |
| 37 | +- test api checks using `npx checkly test` command pass env variables using `-e` parama, use `--record` to persist results and `--verbose` to be able to see all errors |
| 38 | + |
| 39 | +### Authentication Setup Scripts |
| 40 | + |
| 41 | +- setupScripts should be flat scripts, no functions, no exports, they will be executed straight by Checkly |
| 42 | +- use axios for making http requests |
| 43 | +- read the input credentials from env variables using process.env |
| 44 | +- pass auth tokens to the request object using `request.headers['key'] = AUTH_TOKEN_VALUE` |
0 commit comments