feat: move logic from generate.js to api-endpoint#928
feat: move logic from generate.js to api-endpoint#928eddiejaoude merged 1 commit intonextjs-livefrom
Conversation
Cahllagerfeld
left a comment
There was a problem hiding this comment.
pointed out to spots which are a bit fragile, but worked in my tests
| const relativeDir = path.resolve("./public", "profiles"); | ||
| const files = fs.readdirSync(relativeDir); | ||
|
|
||
| const profiles = await Promise.all( |
There was a problem hiding this comment.
This is a bit fragile imo. If one Promise fails, Promise.resolve wont resolve successfully. I think a propper error-handling needs to be added here. Its discussable if with this, or a future PR.
| const profiles = await Promise.all( | ||
| files.map(async (file) => { | ||
| const response = await fetch( | ||
| `http://localhost:3000${path.join("/", "profiles", file)}` |
There was a problem hiding this comment.
We should maybe think of a solution of not hardcoding the URL although it needs to be a absolute one.
(Afaik, in index.js the Request-URL is also hardcoded.)
There was a problem hiding this comment.
I think if a request url the join is not required, only if it is a disk path
I wonder if we can use a relative url here? /profiles/...
|
I am going to merge this and more work can continue in the |
closes #923
Definition of Done
generate.jsgenerate script