-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Q&A: How can I remove the service name from the api endpoint? #315
Comments
@nnthuan How exactly are you configuring the REST? |
Hi @intech export default class ApiService extends Service {
public constructor(broker: ServiceBroker) {
super(broker);
this.parseServiceSchema({
name: "ProductService",
mixins: [ApiGateway],
// More info about settings: https://moleculer.services/docs/0.14/moleculer-web.html
settings: {
port: process.env.PORT || 3000,
routes: [{
path: "/",
...
}]
},
actions: {
getProduct: {
rest: "GET /products/:id",
....
}
} Expected: Actual: I don't want to have |
export default class ApiService extends Service {
public constructor(broker: ServiceBroker) {
super(broker);
this.parseServiceSchema({
name: "ProductService",
mixins: [ApiGateway],
// More info about settings: https://moleculer.services/docs/0.14/moleculer-web.html
settings: {
port: process.env.PORT || 3000,
routes: [{
path: "/",
aliases: {
"GET /products/:id": "ProductService.getProduct"
}
...
}]
},
actions: {
getProduct: {
....
}
} |
I see doing it manually through the alias, but API Gateway publishes APIs from various services, which is tired with a large amount. Is there a setting that applies to all? |
@nnthuan Generation automatically goes according to the |
Resolved export default class ApiService extends Service {
public constructor(broker: ServiceBroker) {
super(broker);
this.parseServiceSchema({
name: "ProductService",
mixins: [ApiGateway],
// More info about settings: https://moleculer.services/docs/0.14/moleculer-web.html
settings: {
port: process.env.PORT || 3000,
rest: '/', // <========== HERE
routes: [{
path: "/",
...
}]
},
actions: {
getProduct: {
rest: "GET /products/:id",
....
}
} |
Q&A: How can I remove the service name from the API endpoint?
When run service, API endpoint like this
/${SERVICE NAME}/products/:id
<-- AutoExpected:
/products/:id
"moleculer": "^0.14.24",
"moleculer-web": "^0.10.4",
The text was updated successfully, but these errors were encountered: