express.js sample apps [closed]

2020-06-17 05:48发布

问题:

I am starting an express.js project. I want to look at code of exiting large apps, especially their file system structure. Anyone knows of apps that use express.js and are on github?

回答1:

Here's my layout.

./myapp
  ./public -- static files
  ./modules -- modules I made for reusability
  ./routes -- like controllers 
  ./log  -- app log file
  ./views -- ejs views
  ./config -- config.development.js, config.global.js
  ./templates -- email templates (text/html in ejs)
  ./pid -- for server
  ./init -- git post-receive hook for deploy
  ./models -- mongoose schemas


回答2:

Take a look at my answer to ExpressJS How to structure an application. You can also look at the repo for my own web site, which although neither large nor exciting, is an express app and has a pretty sane filesystem and code organization scheme (IMHO).

Of coures, browse the list of ExpressJS applications on the main Express site. Not sure which if any are open source, but have a look through those.



回答3:

Express is kind of notorious for not really having any specific guidance on how to lay out the folder structure and build big apps. To be fair, it's not really intended to be a "Rails", it's more of a light layer that simplifies basic HTTP features.

There may be some Express examples on Github, but none off the top of my head.

You may want to take a look at RailwayJS which is a lot closer to the expected "Rails" on top of Express. You may also want to take a look at Geddy which is used for large-scale apps. Geddy is not Express-based, but has more explicit guidance on how to structure everything.



回答4:

In my express app, I have more or less this structure:

project
|--app.js
|--bin
|  `--shell scripts and stuff*
|--docroot
|  `--static files, etc*
|--node_modules
|  `--npm downloads go here*
|--lib
|  |--vendor
|  |  `--jar files and stuff*
|  |--my-custom-middleware1.js
|  `--my-custom-middleware2.js
|--package.json
|--README.md
`--templates
   `--a bunch of templates*

Works fairly well for what I need.



回答5:

This not a very large scale project but it gives you a basic idea about how to structure you application it's a REST API https://github.com/khurrumqureshi/BotnikServer



回答6:

Have a look at the examples of express that you can find at the github repository. If you are into MVC there is also an example for it. They give you a good first idea on how to structure your app.

More on how to structure your app is in the express faq under "How should I structure my application?"



回答7:

There are a ton of apps on github that use express. For a large project you can look at krakenjs.com. Which is not really an app but more of a structure for an app that was created by paypal when they switched from java to node.js.

You can also look at more full stack app structures like mean.io or meanjs.org if you want to use angular.js and mongodb. Even if you don't you can get an idea of how they structure their code.