Creating Endpoint
This command creates a new REST Endpoint in the current Njs2 Project.njs2 endpoint helloWorld
Following are the files created under methods directory.
src/methods/helloWorld/init.jsclass ExampleHelloWorldInitalize extends baseInitialize {
constructor() {
super();
this.initializer = {};
this.initializer.isSecured = false; // values: true/false
this.initializer.requestMethod = ['GET']; // requestMethod: ['GET', 'POST', 'PUT', 'DELETE']
}
getParameter() {
const param = {};
return { ...param };
}
}
module.exports = ExampleHelloWorldInitalize;
src/methods/helloWorld/action.jsclass ExampleHelloWorldAction extends baseAction {
async executeMethod() {
this.setResponse("SUCCESS");
return "Hello World!..";
}
}
module.exports = ExampleHelloWorldAction;