iliekcomputers: I noticed in AB that we were still using service integrations for readthedocs instead of webhooks. I've updated it to a webhook
2019-06-06 15712, 2019
alastairp
not sure what LB uses
2019-06-06 15752, 2019
alastairp
theoretically it builds when we make a release, which should coincide with our deployments. We can test it next time we release
2019-06-06 15701, 2019
D4RK-PH0ENiX joined the channel
2019-06-06 15723, 2019
D4RK-PH0ENiX has quit
2019-06-06 15749, 2019
D4RK-PH0ENiX joined the channel
2019-06-06 15756, 2019
akhilesh
Mr_Monkey: If no identifiers found for an existing entity, and request wants to access identifiers by `/<entity>/<bbid>/identifiers `, what will be the status of response code and message?
2019-06-06 15754, 2019
akhilesh
status code and message?
2019-06-06 15712, 2019
akhilesh
as response
2019-06-06 15727, 2019
Mr_Monkey
You should return a valid object but with no identifiers
2019-06-06 15705, 2019
akhilesh
ok
2019-06-06 15740, 2019
Mr_Monkey
That way, as a consumer of the API, I know that if I send a correct request I can expect, say, an array, even if it is empty
Mr_Monkey: what should message, if the entity does not exist and request require identifiers? , the status code is 404.
2019-06-06 15742, 2019
Mr_Monkey
akhilesh: The same as a get request for the entity itself. We'll review the messages later, but something along the lines of "Entity not found"
2019-06-06 15711, 2019
akhilesh
ok
2019-06-06 15714, 2019
Mr_Monkey
or "Work not found" in this case
2019-06-06 15753, 2019
Mr_Monkey
akhilesh: I think using express middleware might be helpful. Anywhere there is a `:bbid` in the routes, use a middleware to load the entity from the DB. That means there is only on place you need to return a 404 if the entity is not found
2019-06-06 15710, 2019
Mr_Monkey
I'll find you an example of how it is used in the BB website
I Think in BB website, first load entity data in middleware because the entity is required to create props with help of that data. Mr_Monkey
2019-06-06 15706, 2019
akhilesh
Is it an issue with the method used by me?
2019-06-06 15718, 2019
Mr_Monkey
akhilesh: By using middleware, instead of calling `getWorkFromDB` for each endpoint, and having to check if the entity exists, send a 404 if it doesn't, etc… you end up having that mechanism in a single place, the middleware
2019-06-06 15752, 2019
Mr_Monkey
So that if you want to change something in that mechanism, you only have one place to change it instead of in each endpoint, wich would be error prone
2019-06-06 15736, 2019
yvanzo
hey iliekcomputers, lemme know when you have time to debug sir :)
2019-06-06 15741, 2019
iliekcomputers
yvanzo: hey, i'm up for doing it right now, what's up? :D
Trying to understand which part is failing to start with.
2019-06-06 15759, 2019
Mr_Monkey
akhilesh: I'm trying to think of the most elegant solution to require different 'relations' when loading an entity from the DB depending on the endpoint. There's a good solution I'm sure, but in any case having a common entity loader for all entity endpoints will make the code much more manageable
2019-06-06 15740, 2019
iliekcomputers
right, okay, let me try to set it up and reproduce it.
2019-06-06 15732, 2019
yvanzo
iliekcomputers: you don’t need replication token, and you should use development setup
2019-06-06 15735, 2019
Mr_Monkey
akhilesh: As a first refactoring step, having a common function you can call from any entity endpoint that: checks the bbid is valid, loads the entity with relations, checks if the entity exists and sends a 404 otherwise is a good first step
2019-06-06 15722, 2019
akhilesh
Mr_Monkey: then, what about load entity via middleware plan?
2019-06-06 15725, 2019
Mr_Monkey
akhilesh: I need a bit more time to find an elegant solution for how to call it with different sets of relations to load, but you can still go ahead and create a single function `loadEntity(req, res, relations)`
2019-06-06 15748, 2019
Mr_Monkey
(passing `res` so that in that function you can send a 404 if there's no entity)
2019-06-06 15709, 2019
akhilesh
ok
2019-06-06 15713, 2019
Mr_Monkey
and using req to attach the loaded entity to the request
2019-06-06 15746, 2019
Mr_Monkey
It's pretty close already to how middleware works in express
2019-06-06 15718, 2019
Mr_Monkey
akhilesh: I think you should be able to do this: `router.get('/:bbid/aliases', makeEntityLoader('Work', ['aliasSet.aliases.language'], 'Work not found'), async (req, res, next) => {
2019-06-06 15718, 2019
Mr_Monkey
…`, the makeEntityLoader middleware can then access req.params.bbid
2019-06-06 15718, 2019
Mr_Monkey
You should be able to copy the existing `makeEntityLoader` function and simplify it for your need
I dont think old people do that sort of stuff anymore.
2019-06-06 15720, 2019
culinko
see the example here: https://i.imgur.com/DFWukhg.png - the red border shows the frame with the image link. it's interesting that it always stretches exactly to the end of lines of release/types/filename rows. shouldn't the frame only be around the image?
MBS-10220: The frame with CA link has bigger width than the thumbnail image
2019-06-06 15727, 2019
akhilesh
Mr_Monkey: look into above, something is wrong, I think how to pass bbid
2019-06-06 15742, 2019
Mr_Monkey
akhilesh: Can you describe what's happening?
2019-06-06 15759, 2019
Mr_Monkey
akhilesh: Ah, I see something that might be the problem. I think `return async (req, res, next, bbid)` is incorrect. You shouldn't have bbid in there, but instead get it from the req object: req.params.bbid
2019-06-06 15728, 2019
pristine__
ruaok: seen
2019-06-06 15743, 2019
Mr_Monkey
`(req, res, next, bbid)` would be a valid signature for router.param
2019-06-06 15743, 2019
pristine__
shouldn't that be msid?
2019-06-06 15748, 2019
pristine__
and not mbid
2019-06-06 15743, 2019
akhilesh
Mr_Monkey: I confused with this, May you push this for only one endpoint please?