First Look Behind the Curtain

I've made some head way on separating many of the routes into there own files. This should help moving forward, previously everything was in just the main index.js file. Now that this is done I thought it was time to touch on a bit of the code thats here. Let's jump right in.

Directory Structure

Having a good structure setup makes it much easier to move around the project. If your looking for a misbehaving route the just look in the routes folder. There are generators that will take care of basic setup, Express Generator for instance, for some reason I've never used them. I usually start with an empty directory and create a package.json and an index.js to get started. Once I've got something taking shape I'll split it up as needed. Below you can see the (slightly edited) tree.

.
├── Dockerfile
├── Makefile
├── bower.json
├── data
│   ├── areaDescriptions.json
│   ├── areas.json
│   ├── creatures.json
│   ├── npcs.json
│   └── weather.json
├── dpkg
│   └── 01_nodoc
├── gulpfile.js
├── index.js
├── package.json
├── public
│   ├── css
│   │   └── screen.css
│   ├── favicon.ico
│   ├── img
│   │   ├── armourer-header.png
│   │   ├── bank-header.png
│   │   ├── forest-header.png
│   │   ├── healer-header.png
│   │   ├── hunt-header.png
│   │   ├── inn-header.png
│   │   ├── patreon_mini_orange.png
│   │   ├── town-header.png
│   │   ├── trainer-header.png
│   │   ├── twitter-wrap.png
│   │   ├── twitter.png
│   │   └── weapons-header.png
│   ├── js
│   │   ├── webtrends.load.js
│   │   └── webtrends.min.js
│   └── vendor
│       ├── jquery
│       ├── normalize.css
│       └── webtrends-bower
├── routes
│   ├── bank.js
│   ├── battle.js
│   ├── character.js
│   ├── healer.js
│   ├── index.js
│   ├── inn.js
│   ├── login.js
│   └── passport.js
├── swarm.json
├── test
│   └── index.js
└── views
    ├── battle.hbs
    ├── character.hbs
    ├── default.hbs
    ├── location.hbs
    ├── login.hbs
    └── partials
        ├── bank.hbs
        └── footer.hbs

It ends up looking for or less like a generator setup anyway but I find that when I do it the whole thing makes more sense. If your learning Node.js go with whatever way works I say.


That does it for our little peak, next time we'll look into some of the actual code that runs the current version of the server. Also, I really need to finish moving the Docker/Swarm building from Make to Gulp...