Conventions for app.js, index.js, and server.js in node.js?

前端 未结 4 493
-上瘾入骨i
-上瘾入骨i 2021-02-01 14:22

In node.js, it seems I run into the same 3 filenames to describe the main entry point to an app:

  • When using the express-generator package, an
4条回答
  •  有刺的猬
    2021-02-01 14:51

    Where I work, we didn't really settle on a format, so we have some apps with index.js, some with server.js. Also, in some we have a config.js file at the root level, others are in a config folder (so require(config/config.js). We even have one where server.js is in a server folder.

    The trouble comes when we want to automate our deployment process. It becomes like technical debt when we have to make a bunch of minor modifications for each service.

    That said, pick a format that makes sense to you and stick with it.

提交回复
热议问题