Skip to content

Commit

Permalink
0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
victorteokw committed Nov 21, 2024
1 parent 419e742 commit 0326cce
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
edition = "2021"
name = "teodevgroup_teo"
version = "0.3.1"
version = "0.3.2"

[lib]
crate-type = ["cdylib"]

[dependencies]
teo = { version = "0.3.1" }
teo = { version = "0.3.2" }
teo-result = { version = "0.3.0", features = ["napi"] }
napi = { version = "2.16.13", default-features = false, features = ["napi5", "async", "chrono_date", "compat-mode"] }
napi-derive = "2.16.12"
Expand Down
5 changes: 3 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export declare class App {
export declare class HandlerMatch {
path(): Array<string>
handlerName(): string
captures(): {[key: string]: string}
captures(): {[key: string]: string} | any
}
export declare class Request {
version(): string
Expand All @@ -114,7 +114,7 @@ export declare class Request {
cookie(name: string): Cookie | null
cookies(): Array<Cookie>
handlerMatch(): HandlerMatch
captures(): {[key: string]: string}
captures(): {[key: string]: string} | any
bodyObject(): any
setBodyObject(value: unknown): void
teo(): any
Expand Down Expand Up @@ -182,6 +182,7 @@ export declare class Response {
static data(value: unknown): Response
static dataMeta(data: unknown, meta: unknown): Response
static file(path: string): Response
static sendFile(base: string, path: string): Response
static redirect(path: string): Response
setCode(code: number): void
code(): number
Expand Down
2 changes: 1 addition & 1 deletion src/request/handler_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl HandlerMatch {
self.inner.handler_name()
}

#[napi(ts_return_type = "{[key: string]: string}")]
#[napi(ts_return_type = "{[key: string]: string} | any")]
pub fn captures(&self, env: Env) -> Result<JsObject> {
let captures_map = self.inner.captures();
let mut js_object = env.create_object()?;
Expand Down
2 changes: 1 addition & 1 deletion src/request/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl Request {
Ok(HandlerMatch::new(self.teo_request.handler_match()?.clone()))
}

#[napi(ts_return_type = "{[key: string]: string}")]
#[napi(ts_return_type = "{[key: string]: string} | any")]
pub fn captures(&self, env: Env) -> Result<JsObject> {
self.handler_match()?.captures(env)
}
Expand Down
7 changes: 7 additions & 0 deletions src/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ impl Response {
}
}

#[napi(js_name = "sendFile")]
pub fn send_file(base: String, path: String) -> Result<Self> {
Ok(Self {
teo_response: TeoResponse::send_file(base, path)?
})
}

#[napi(js_name = "redirect")]
pub fn redirect(path: String) -> Self {
Self {
Expand Down

0 comments on commit 0326cce

Please sign in to comment.