Page MenuHomePhabricator

[server] add helper function to generate all route paths
ClosedPublic

Authored by varun on Mar 15 2022, 11:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 10:20 PM
Unknown Object (File)
Sun, Nov 10, 12:12 AM
Unknown Object (File)
Sun, Nov 10, 12:12 AM
Unknown Object (File)
Sun, Nov 10, 12:12 AM
Unknown Object (File)
Sun, Nov 10, 12:06 AM
Unknown Object (File)
Tue, Nov 5, 3:19 AM
Unknown Object (File)
Tue, Nov 5, 1:24 AM
Unknown Object (File)
Oct 16 2024, 8:34 AM

Details

Summary

the new base path that web.comm.app will proxy to needs to be added to the express router. this diff makes that change and also deduplicates logic around generating route paths.

depends on D3414

Test Plan

flow, ran the web app and everything looked fine

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tomek requested changes to this revision.Mar 16 2022, 6:48 AM
tomek added inline comments.
server/src/server.js
120–122 ↗(On Diff #10401)

Are you sure it is correct to use an array as a first parameter here?

141 ↗(On Diff #10401)

Should we have another ws entry for commAppBaseRoutePath?

server/src/utils/urls.js
44 ↗(On Diff #10401)

In this case we should use $ReadOnlyArray<string> or string[].

Generally, we should prefer $ReadOnlyArray, but when it is a return value, that is generated inside the function, it doesn't matter that much.

If we need a mutable array, we should usually prefer type[]. We can use Array<> but it's more verbose, so I think it should be used only when necessary (so when type[] doesn't work for some reason).

This revision now requires changes to proceed.Mar 16 2022, 6:48 AM
server/src/server.js
120–122 ↗(On Diff #10401)

yeah, it seems to work but it's unclear if arrays are officially supported. it's probably better to just loop through the array ourselves. fixed in latest revision

141 ↗(On Diff #10401)

No, I think we should just proxy /{new base path}/ws to ws://localhost:3000/ws with apache. This worked fine for me locally

server/src/utils/urls.js
44 ↗(On Diff #10401)

went with string[]

tomek added a reviewer: ashoat.
tomek added inline comments.
server/src/server.js
120–122 ↗(On Diff #10401)

Ok, that makes sense. We can consider creating our own function that loops and configures the paths based on handler and path to avoid a lot of for loops that affect the readability

This revision is now accepted and ready to land.Mar 22 2022, 7:29 AM