nuclei/pkg/js/generated/ts/postgres.ts
Tarun Koyalwar 36985345a9
javascript bindings + docs generation enhancements ( generate typescript defination .d.ts files) (#4487)
* introduce typescript files generation using ast + tmpl

* feat valid ts with scraping

* feat remove old logic + tsdocs for all modules

* fix ikev and related bugs

* typescript docs for js modules

* lint,build + ldap realm fix

* go mod tidy

* fix named imports ast parsing

* fix ast code generation errors

* complete support for ts files generation

* support go global/const in ts docs

* updated template

* feat: typescript using go code generation

* nuke jsdoc generator

* update generated ts dir structure

* fix multifile ts gen issue

* fix panic in ts code gen

* fix test

* update docs of js libs

* feat: add doc+example for every js class,function,method

* fix missing quotes in ikev example

---------

Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
2024-02-07 21:45:40 +05:30

97 lines
2.7 KiB
TypeScript
Executable File

/**
* PGClient is a client for Postgres database.
* Internally client uses go-pg/pg driver.
* @example
* ```javascript
* const postgres = require('nuclei/postgres');
* const client = new postgres.Client();
* ```
*/
export class PGClient {
// Constructor of PGClient
constructor() {}
/**
* IsPostgres checks if the given host and port are running Postgres database.
* If connection is successful, it returns true.
* If connection is unsuccessful, it returns false and error.
* @example
* ```javascript
* const postgres = require('nuclei/postgres');
* const isPostgres = postgres.IsPostgres('acme.com', 5432);
* ```
*/
public IsPostgres(host: string, port: number): boolean | null {
return null;
}
/**
* Connect connects to Postgres database using given credentials.
* If connection is successful, it returns true.
* If connection is unsuccessful, it returns false and error.
* The connection is closed after the function returns.
* @example
* ```javascript
* const postgres = require('nuclei/postgres');
* const client = new postgres.Client();
* const connected = client.Connect('acme.com', 5432, 'username', 'password');
* ```
*/
public Connect(host: string, port: number, username: string): boolean | null {
return null;
}
/**
* ExecuteQuery connects to Postgres database using given credentials and database name.
* and executes a query on the db.
* If connection is successful, it returns the result of the query.
* @example
* ```javascript
* const postgres = require('nuclei/postgres');
* const client = new postgres.Client();
* const result = client.ExecuteQuery('acme.com', 5432, 'username', 'password', 'dbname', 'select * from users');
* log(to_json(result));
* ```
*/
public ExecuteQuery(host: string, port: number, username: string): SQLResult | null | null {
return null;
}
/**
* ConnectWithDB connects to Postgres database using given credentials and database name.
* If connection is successful, it returns true.
* If connection is unsuccessful, it returns false and error.
* The connection is closed after the function returns.
* @example
* ```javascript
* const postgres = require('nuclei/postgres');
* const client = new postgres.Client();
* const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname');
* ```
*/
public ConnectWithDB(host: string, port: number, username: string): boolean | null {
return null;
}
}
/**
* SQLResult Interface
*/
export interface SQLResult {
Count?: number,
Columns?: string[],
}