1.0.3 • Published 11 months ago
nest-client v1.0.3
nest-client
nest.js client stub library
This allows almost no additioanl effort to make client SDK by coping from the nest.js controller file in the server codebase.
Tips: you can auto generate the client stub using nest-gen
Example (client side)
import { Body, Controller, Get, injectNestClient, Param, Post, setBaseUrl } from "nest-client";
setBaseUrl("http://127.0.0.1:3000"); // set the default baseUrl
@Controller("animal")
class Animal {
constructor() {
injectNestClient(this, {
baseUrl: "http://127.0.0.1:3000", // optional if called setBaseUrl()
allowNonRestMethods: true // default false
});
}
@Post("talk")
talk(): any {
// these code will not be called, server response will be returned instead
console.log("talking manually");
return "manually";
}
@Get("name")
name(): any {
}
@Get("/get_echo/:Msg/:User")
get_echo(@Param("Msg")Msg, @Param("User")User) {
}
@Post("/post_echo")
post_echo(@Body("Msg")Msg) {
}
customMethod() {
return 'this method will not be override'
}
}
Running the Example
cd examples/server
npm i
npm run start & sleep 5
cd ../../
npm test
License
This project is licensed with BSD-2-Clause
This is free, libre, and open-source software. It comes down to four essential freedoms [ref]:
- The freedom to run the program as you wish, for any purpose
- The freedom to study how the program works, and change it so it does your computing as you wish
- The freedom to redistribute copies so you can help others
- The freedom to distribute copies of your modified versions to others
1.0.2
11 months ago
1.0.1
11 months ago
1.0.3
11 months ago
1.0.0
1 year ago
0.6.1
3 years ago
0.6.0
3 years ago
0.5.5
4 years ago
0.5.4
4 years ago
0.5.3
4 years ago
0.5.2
4 years ago
0.5.1
5 years ago
0.5.0
5 years ago
0.4.4
5 years ago
0.4.3
5 years ago
0.4.2
5 years ago
0.4.1
5 years ago
0.4.0
5 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.2.0
6 years ago
0.1.0
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago