Closed francoisromain closed 6 years ago
following up: login
could return infos about the logged-in user:
{
"status": "success",
"data": {
"_id": 123456,
"name": "Lulu",
"description": "Lulu desc…"
},
"message": "User logged in"
}
I just started a new branch which should address the main point: consistent response format.
Available for testing in branch develop
since commit 15bee85
Note that /login
route has not yet been updated but a new issue #83 has been created to keep track of this request.
It seems to work fine, but now there is an error 500 on update
actions with corpora, media, layers and annotations (updates only work fine on users and groups).
I cannot reproduce the error locally:
>>> from camomile import Camomile
>>> client = Camomile('http://localhost:3000')
>>> client.login(USERNAME, PASSWORD)
>>> result = client.updateCorpus(CORPUS_ID, description={'test': 'test'})
>>> print(result['status'])
success
>>> print(result['data']['description'])
{'test': 'test'}
Can you please clarify?
When I try to update a corpus / media / layer / annotation from camomile-ui, using camomile-server and camomile-client-javascript, it returns an error 500.
The error logged from camomile-ui does not say much:
Warning: a promise was rejected with a non-error: [object Undefined]
It comes from the bluebird library used by request-promise (http://bluebirdjs.com/docs/warning-explanations.html)
The error logged from camomile-client-javascript points to MongoDB:
"StatusCodeError: 500 - {"status":"error","data":null,"message":{"name":"MongoError","message":"Unknown modifier: $pushAll","driver":true,"index":0,"code":9,"errmsg":"Unknown modifier: $pushAll"}}
at new StatusCodeError (webpack-internal:///../camomile-client-javascript/node_modules/request-promise-core/lib/errors.js:32:15)
$pushAll
is deprecated since v.2.4 of mongodb (-> https://docs.mongodb.com/manual/reference/operator/update/push/)
Do you have an idea?
Might be related to https://github.com/Automattic/mongoose/issues/5870
Downgrading MongoDB to < 3.6 should solve the problem until mongoose 5.x is out.
Just opened issue #85 as this is in fact not related to this one... Closing this one, then...
Sometimes the api response is a message (ie:
login
respond with"success": "Authentication succeeded."
) sometimes it's an object (ie:me
respond with{ "_id": "555299eff80f910100d741d1", "description": "", "role": "user", "username": "johndoe" }
). It would be cleaner to make it consistent.For example follow jsend specs:
Successful request:
Failed request: