Context
• We’re a team using the nodejs agent.
• Myself have 5y+ experience overall on Forest, especially on the Ruby agent (new company from 0, we’ve decided to go on TypeScript and explain the nodejs agent selection)
• We’re architecture in micro-services and the back-office service is a read-only tool, databases connection are all connected with a read-replica
• Our backend services expose specific routes to interact with internal back-office resources
Feature(s) impacted
We want to override the default behavior of Forest to allow managing creation of resources to domain service (microservices architecture)
We’ve followed the doc section > Collection override | Node.js Developer Guide
Observed behavior
We’re pretty lost on the expected behavior of the code block. The documentation should help us to manage:
• How should the response look like? a JSON object? a Collection database fetched object?
• How to manage the errors part?
For info, we’re using axios to make HTTP requests to our backend service.
Expected behavior
collection_name.overrideCreate(async context => {
const { data } = context;
axios.post('http://backend.api/post-route', data[0])
.then(response => {
return [response.data]; // How should the response be formatted for Forest?
})
.catch(err => {
console.log(err);
return err; // How error(s) response should be formatted?
});
});
Context
- Agent technology: nodejs
- Agent (forest package) name & version: ^1.0.0
- Database type: postgres