@odg/latam-test v1.3.2
Table of Contents
- ๐ Benefits
- ๐ Libraries
- ๐ Dependencies
- ๐ Use Template
- โฉ Get Started
- ๐ Cycle Time
- ๐ป Prepare to develop
- ๐ Start Project
- ๐จ Build and Run
- ๐งช Teste Code
๐ Benefits
- ๐ Speed start new crawler using typescript
- ๐จ Over 800 rules for pattern, possible errors and errors in Linter
- ๐ Code quality guaranteed
- ๐ข AutoReview when opening a pull-request/merge

- ๐งช Automatic Test when opening pull-request/merge
- ๐ฆ Automatic Package and release generate on merge
- โ๏ธ IOT/IOC (Inversion of Control) for easy use of libraries
- ๐ข Make:Files Command to make base files
๐ Libraries
๐ Dependencies
- Node.js 18 or later
- Yarn Optional/Recommended
- Playwright
- For web scraping / crawling / automation
- @odg/axios
- Example to message request with axios
- @odg/chemical-x
- Base For crawlers and helpers project
- @odg/command
- Commands to make:files
- @odg/events
- Abstract Events with async events
- @odg/exception
- Create custom exception to debug and history
- @odg/json-log
- Convert your logs exception, request, in JSON before send
- @odg/log
- Interface of logs
- @odg/message
- Interface of request and messages
- @odg/tsconfig
- Base Tsconfig to build project
๐ Use Template
Click in use this template button and clone your template project

๐ Change to Puppeteer
To change you crawler to use puppeteer you change ./engine.ts file for:
import puppeteer, {
type Browser,
type PuppeteerLaunchOptions,
type Page,
type BrowserContext,
type PuppeteerNode,
} from "puppeteer";
export type BrowserTypeEngine = PuppeteerNode;
export type BrowserClassEngine = Browser;
export type ContextClassEngine = BrowserContext;
export type PageClassEngine = Page;
export type BrowserOptionsEngine = PuppeteerLaunchOptions;
export const browserEngine = puppeteer;โฉ Get Started
๐ฆป Event / Listeners
Events can be fired with EventBusInterface Example Include the execution of your page in an event so that you can execute any page at any time
export class ExampleEventListener implements EventListenerInterface<EventTypes, EventName.ExampleEvent> {
@inject(ContainerName.Logger)
public readonly log!: LoggerInterface;
public async handler(_receivedData: unknown) {
await this.log.info('Example Event Listener');
}
}Register all Events name in
./src/app/Enums/EventName.tsRegister all Events Types in
./@types/EventsInterface.tsRegister your events in EventServiceProvider to automatic listeners.
โ๏ธ Selector
The selectors are in the selectors folder
export const googleSearchSelector = {
searchInput: "input[name=\"q\"]",
buttons: {
submit: "input[name=\"btnK\"] >> visible=true",
},
};
export type GoogleSearchSelectorType = typeof googleSearchSelector;Register all Selectors in
./src/app/Selectors/index.ts
โ๏ธ Container Bind
this.bind(
ContainerName.Logger,
).to(ConsoleLogger).inSingletonScope();Register all Container name in
src/app/Enums/ContainerName.tsRegister all Container Inject insrc/app/Container.ts
โ Extract Text Helper
Use Str, Num, Arr helpers class to manipulate Text, Numbers and Arrays
import { Str } from "@odg/chemical-x";
const value = new Str(
this.page.locator("#money").innerText(),
).money();๐ข Make File
To Make a file run command
Use this to make Page, Handler, Selectors...
yarn odg makeExample to make Page File
yarn odg make:page Search
# help with
yarn odg make:page --help๐ Cycle Time
๐ฝ๏ธ Project Life Cycle
Project Life cycle

๐ Service Life Cycle
Example Service Life Cycle

๐ฆ Page Life Cycle
Example Page Life Cycle

๐ Handler Life Cycle
Example Handler Life Cycle

๐ป Prepare To Develop
Copy .env.example to .env and add the values according to your needs.
๐ Start Project
First install dependencies with the following command
yarn install
# or
npm install๐จ Build and Run
To build the project, you can use the following command
if you change files, you need to run
yarn buildandyarn startagain
yarn build && yarn start
# or
yarn dev๐งช Teste Code
To Test execute this command
yarn test
# or
yarn test:watch