iliekcomputers: I noticed in AB that we were still using service integrations for readthedocs instead of webhooks. I've updated it to a webhook
not sure what LB uses
theoretically it builds when we make a release, which should coincide with our deployments. We can test it next time we release
D4RK-PH0ENiX joined the channel
D4RK-PH0ENiX has quit
D4RK-PH0ENiX joined the channel
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?
status code and message?
as response
Mr_Monkey
You should return a valid object but with no identifiers
akhilesh
ok
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.
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"
akhilesh
ok
Mr_Monkey
or "Work not found" in this case
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
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
Is it an issue with the method used by me?
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
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
yvanzo
hey iliekcomputers, lemme know when you have time to debug sir :)
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.
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
iliekcomputers
right, okay, let me try to set it up and reproduce it.
yvanzo
iliekcomputers: you don’t need replication token, and you should use development setup
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
akhilesh
Mr_Monkey: then, what about load entity via middleware plan?
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)`
(passing `res` so that in that function you can send a 404 if there's no entity)
akhilesh
ok
Mr_Monkey
and using req to attach the loaded entity to the request
It's pretty close already to how middleware works in express
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) => {
…`, the makeEntityLoader middleware can then access req.params.bbid
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.
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
akhilesh
Mr_Monkey: look into above, something is wrong, I think how to pass bbid
Mr_Monkey
akhilesh: Can you describe what's happening?
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
pristine__
ruaok: seen
Mr_Monkey
`(req, res, next, bbid)` would be a valid signature for router.param
pristine__
shouldn't that be msid?
and not mbid
akhilesh
Mr_Monkey: I confused with this, May you push this for only one endpoint please?