I'm currently trying to write a service with the MEAN stack to handle actions on a game. I've followed boiler plates up to the point where I now need to add custom actions.
I have a game model which I can do the usual, save, update, delete on. But I want to add actions like join/leave game. I have tried this currently, for the game service:
window.angular.module('ngff.services.games', [])
.factory('Games', ['$resource',
function($resource){
return $resource(
'games/:gameId/:actionId',
{
gameId: '#_id',
actionId: '#actionId'
},
{
update: {
method: 'PUT',
params: {
actionId: null
}
},
join: {
method: 'POST',
params: {
actionId: 'join'
}
},
leave: {
method: 'POST',
params: {
actionId: 'leave'
}
}
}
);
}]);
Update works correctly, but my other requests always seems to default post to games/:gamesId without adding the actionId on the end. How can I change the location that my form posts to?
I already have the backend worked out, and manually posting to my apis works fine.
I had all this working without angular, but I've never used it before and I'm a little stuck.
Thanks
Ryan
Related
I have used following json for custom namespace object in kubernetes.
const azureIdentityJson = {
'apiVersion': 'aadpodidentity.k8s.io/v1',
'kind': 'AzureIdentity',
'metadata': {
'name': identityName,
'namespace': namespace,
'annotations': {
'aadpodidentity.k8s.io/Behavior': 'namespaced'
}
},
'spec': {
'type': 0,
'resourceID': managedIdentityId,
'clientID': managedIdentityClientId
}
};
await k8sClient.createCustomObject('aadpodidentity.k8s.io', 'v1', 'azureidentities', azureIdentityJson);
and createCustomObject function is as follows.
public async createCustomObject (customTypeName: string, customVersion: string, plural: string, customObjectManifest: any): Promise<any> {
const client = this.kubeConfig.makeApiClient(k8s.CustomObjectsApi);
return new Promise<string>((resolve, reject) => {
client.createNamespacedCustomObject(customTypeName, customVersion, customObjectManifest.metadata.namespace ? customObjectManifest.metadata.namespace : 'default', plural, customObjectManifest).then(
(response) => {
resolve(response);
},
(err) => {
reject(err.response && err.response.body ? err.response.body : err);
},
);
});
}
when executing, getting 404, page not found error. No other information were there. It was working fine earlier. Please help here. Stuck almost a month now.
Thanks in advance
CustomResources store structured data in custom fields likebuilt-in fields apiVersion, kind and metadata, which are explicitly validated by the api.There might be issue among one of these.
Try to upgrade Aks version or node js version.
custom resource objects must sometimes be converted between the
version they are stored at and the version they are served at. If the
conversion involves schema changes and requires custom logic, a
conversion webhook should be used. If there are no schema changes, the
default None conversion strategy may be used and only the apiVersion
field will be modified when serving different versions.
Versions in CustomResourceDefinitions | Kubernetes
I'm trying to query from Elastic DB. So for 90000 Records I need to hit elastic DB for two different occasions.My query is as follows.
var queryobj = {
"query": {
"bool": {
"must": [
{
"match": {
"mobile": value
}
}
],
}
}
};
var { _scroll_id, hits, took } = await elasticClient.search({
index: 'mobiledata',
type: '_doc',
scroll: '20m',
filterPath: '_scroll_id,hits.hits._source,took',
size: 10000,
body: queryobj
});
if (hits) {
console.log("hits ", hits);
return hits.hits;
}
return hits;
While trying to exectue this, I'm getting error like :
{ Error: [exception] Trying to create too many scroll contexts. Must be less than or equal to:
[500]. This limit can be set by changing the [search.max_open_scroll_context] setting.
status: 500,
displayName: 'InternalServerError',
message: '[exception] Trying to create too many scroll contexts. Must be less than or equal to:
[500]. This limit can be set by changing the [search.max_open_scroll_context] setting.',
Can anybody help me how to fix this error?
await elasticClient.clearScroll({scroll_id: _scroll_id});
Whenever you want to close the scroll api and open another scroll api, please run the above code.
It works fine for me.
Lately I have found mailchimp-api-v3 to be quite useful for managing our .1k list. Currently, I use the following to (1) create new tags, and (2) add the tag to contacts:
const MC = require('mailchimp-api-v3');
const mailchimp = new MC('<apiKey>');
mailchimp.batch([{
method: 'POST',
path: '/lists/<list_id>/segments',
body: {
name: '<tag1>',
static_segment: [<contact_list1>]
}
}, {
method: 'POST',
path: '/lists/<list_id>/segments',
body: {
name: '<tag2>',
static_segment: [<contact_list2>]
}
}])
.then(results => {
console.log( results );
})
.catch(errs => {
console.log( errs );
});
Sometimes there's need to add an existing tag to contacts. Whenever I try to use the above code, as expected, I get tag already exists error and contacts are not tagged with this existing tag.
How do I get a list of all existing tags? And how would one add an existing tag to contacts?
I finally figured out how to do that. The just updated documentation is much easier to navigate that before. It's now evident that there are two ways of adding a tag/segment to (a) member(s): you can add a single tag to a member or you can add a single tag to many members:
Bulk add with members_to_add: array
{
method: 'POST',
path: '/lists/{list_id}/segments/{segment_id}',
body: {members_to_add: [<email-addresses>]}
}
This is indeed what I needed and I have now been using it for a while. Just today I found out the other method:
Single add with email_address: string
{
method: 'POST',
path: '/lists/{list_id}/segments/{segment_id}/members',
email_address: {email_address}
}
We're using Keystone (version 4.0.0-beta.8) as our Node.js CMS for the first time for a project and we're really liking it. However we're running into a vital missing feature of the CMS and that is adding custom components to the admin views.
What we would like to achieve is to add a custom React component to one of the Keystone admin screens and populate it with data from a field watch function
This component should only be visible for one of the list models. Right now, the only way to do this, is to edit one of the core files:
/node_modules/keystone/admin/client/App/screens/Item/index.js
and add some conditional rendering around it:
{(this.props.params.listId === 'my-list-model') ? (
<MyComponent>{this.props.params.listId}</MyComponent>
) : null }
This works, but is not ideal off-course since you're overwriting core files. But I could overcome this short-come if I knew how I can feed this custom component with data from the Keystone list model declaration:
In: /server/models/MyListModel.js
import keystone from 'keystone';
import { someFunction } from './myFunctions';
var MyListModel = new keystone.List('MyListModel', {
map: { name: 'title' },
});
MyListModel.add({
title: { type: String, required: true },
data: { type: Types.Code, language: 'json', watch: 'title', value: watchTitle, noedit: true },
});
MyListModel.register();
function watchTitle(callback) {
if (this.title) {
function cb(error, result) {
if (result) {
// Send result to React Component in Admin screen
}
callback(error, result);
}
someFunction(this.title, cb);
} else {
callback(null, '');
}
}
Does anyone bump into the same issue or have any clue how to send data to a custom component in the react admin view of Keystone?
Thanks a lot!
i have a problem with Node JS loop-back include filter when i make a query .Every time its giving all records in response.but i want only those records that holds the sportid which i am passing in query filter.
var request = {
method: 'get',
command: 'UserPersonalinfos',
query: {
filter: {
"include": {
"relation": "UserRegistration",
"where": {
"sportid": data[0].id
}
},
limit:5
}
},
headers: {
access_token:userAccessToken.id,
}
};
if sportid exists then it should return object otherwise it should not, but in this case its returns all UserPersonalinfos records and adding UserRegistration object to UserPersonalinfos object
As per https://stackoverflow.com/a/32933383/344022 there's nothing officially available yet. There is a fork of the loopback-connector by #DiogoDoreto that does attempt to provide it. I haven't tried it, but if you were to use it you would do the following in a filter:
"where": {
"UserRegistration": {
"where": {
"sportid": data[0].id
}
}
}
The answer linked above also suggests some other ways of achieving what you want.