]> git.kaiwu.me - njs.git/commitdiff
Types: added TS types for ngx properties added in 25b55a064e42.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 24 May 2023 06:47:43 +0000 (23:47 -0700)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 24 May 2023 06:47:43 +0000 (23:47 -0700)
test/ts/test.ts
ts/ngx_core.d.ts

index c1ac3dc5ff34419a5f4984e44b1f6f2fba73bdd9..13b1157a9a1223c7f33fae24fe9fbc63e3d2c410 100644 (file)
@@ -297,7 +297,7 @@ function njs_object() {
 }
 
 function ngx_object() {
-    ngx.log(ngx.INFO, 'asdf');
-    ngx.log(ngx.WARN, Buffer.from('asdf'));
-    ngx.log(ngx.ERR, 'asdf');
+    ngx.log(ngx.INFO, ngx.conf_prefix);
+    ngx.log(ngx.WARN, Buffer.from(ngx.error_log_path));
+    ngx.log(ngx.ERR, ngx.version);
 }
index d9cbb785f5042873abb35d2a1d1a3b3d7bcd6cb9..f2bd7cab2da9f606b5d2bf6ddd311108f20dbd0d 100644 (file)
@@ -243,16 +243,38 @@ interface NgxFetchOptions {
 }
 
 interface NgxObject {
-    readonly INFO: number;
-    readonly WARN: number;
+    /**
+     * A string containing an optional nginx build name, corresponds to the
+     * --build=name argument of the configure script, by default is ""
+     *  @since 0.8.0
+     */
+    readonly build: string;
+    /**
+     * A string containing the file path to current nginx configuration file
+     * @since 0.8.0
+     */
+    readonly conf_file_path: string;
+    /**
+     * A string containing the file path to directory where nginx is currently
+     * looking for configuration
+     * @since 0.7.8
+     */
+    readonly conf_prefix: string;
+    /**
+     * The error level constant for ngx.log() function.
+     * @since 0.5.1
+     */
     readonly ERR: number;
     /**
-     * Writes a string to the error log with the specified level
-     * of logging.
-     * @param level Log level (ngx.INFO, ngx.WARN, ngx.ERR).
-     * @param message Message to log.
+     * A string containing the file path to the current error log file
+     * @since 0.8.0
      */
-    log(level: number, message: NjsStringOrBuffer): void;
+    readonly error_log_path: string;
+    /**
+     * The info level constant for ngx.log() function.
+     * @since 0.5.1
+     */
+    readonly INFO: number;
     /**
      * Makes a request to fetch an URL.
      * Returns a Promise that resolves with the Response object.
@@ -262,6 +284,34 @@ interface NgxObject {
      * @since 0.5.1
      */
     fetch(init: NjsStringOrBuffer | Request, options?: NgxFetchOptions): Promise<Response>;
+    /**
+     * Writes a string to the error log with the specified level
+     * of logging.
+     * @param level Log level (ngx.INFO, ngx.WARN, ngx.ERR).
+     * @param message Message to log.
+     */
+    log(level: number, message: NjsStringOrBuffer): void;
+    /**
+     * A string containing the file path to a directory that keeps server files
+     * @since 0.8.0
+     */
+    readonly prefix: string;
+    /**
+     * A string containing nginx version, for example: "1.25.0"
+     * @since 0.8.0
+     */
+    readonly version: string;
+    /**
+     * A number containing nginx version, for example: 1025000
+     * @since 0.8.0
+     */
+    readonly version_number: number;
+    /**
+     * The warn level constant for ngx.log() function.
+     * @since 0.5.1
+     */
+    readonly WARN: number;
+
 }
 
 declare const ngx: NgxObject;