Skip to main content

REST API

In the event that the standard API generated by the Steedos cannot satisfy the business requirements, you can write a custom API to handle business data on the server.

API Definition

You can define an API as an "action" in the microservice by specifying the "REST" parameter. This declares the current action as an API, allowing you to implement custom functionality for your business requirements.

module.exports = {
name: "example-service",

actions: {
hello: {
rest: { method: 'GET', path: '/hello/:name' },
handler(ctx) {
return {
data: 'Welcome ' + ctx.params.name
}
}
},
me: {
rest: { method: 'GET', path: '/me' },
async handler(ctx) {
return ctx.meta.user
}
},
}
}