Closed ZeevKatz closed 6 years ago
hi @zeevkatz,
yeap! you can do with any service. For example:
@Injectable()
export class AuthorsService extends Service<Author> {
public resource = Author;
public type = 'authors';
public schema: ISchema = {
relationships: {
photos: {
hasMany: true
}
}
};
public getPath(): string {
return 'my_particular_path_for_this_resource_type';
}
}
Maybe I was uncleared, I'd like to change the api host and not a specific service path.
Oh! ok....
I'm thinking on a feature... We can atach new method on service for specials URIs, o just a particular service base url... :thinking:
Created new pull request with solution for this issue. Waiting for your merge...
Hi @pablorsk, Please let me know if there are issues with my last pull request that related to this issue. Jan 30 was really far from now and this is a really important change, Thanks.
I am not sure if i am not too late for possible solution. But maybe it will help for someone one day. Use case is to have one api url for deployment and other for prod. Also not 100% clear that it gonna work for all but you'll get idea.
Create folder under root "environments" with two files environment.ts
export const environment = {
production: false,
someEndpoint : 'http://localhost:55180/',
anotherEndPoint : "http://localhost:55009/x-files/"
};
environment.prod.ts
export const environment = {
production: true,
someEndpoint : 'http://api.superdomain.com/',
anotherEndPoint : "http://api.superdomain.com/no-files/"
};
And then in you service you could use
private rootUrl = environment.someEndpoint + "x-files-documents/";
public getPath(): string {
return this.rootUrl;
}
So when you build with flag prod it gonna take variables from prod file. Easy peasy.
There is a way to change the api path after loading? I'm trying to load the api path from configuration JSON file for dynamic config options in production and set the url only after the config file loading.