SPS Update 1

August 8th 2016

Here's the first project update for Simian Photo Server. It has been a little over 24 hours since I started the project and at the moment the status is thus

  • The build system is set.
  • The web-server is up (though not serving much ATM).
  • The graphql schema is defined and I can see dummy data in graphiql.
  • Usual suspects like config, linting, testing, and logging are set.

The Build System

Gulp

I am using everyone's favourite gulp to build the project. I like to split my gulp tasks into separate files and require all the files into the main gulpfile which itself contains only the very top level tasks. So we have a number of sub-gulpfiles in the gfiles directory and they are all simply imported into the gulpfile. I just find it easier to work with smaller files each dealing with just one particular aspect of the overall project. So for instance gfiles/app.js deals with building the server. It compiles the server side js, lints it and tests it. Similarly gfiles/client-js.js does the same things for client side javascript.

Babel

I have tried getting started with typescript multiple times and each time I end up feeling like it complicates my environment far more than the value it provides. If I were a more disciplined and patient person I might get past this stage, but for now I'm sticking with Babel and the wild world of typeless JavaScript. Because I'm using same technologies as Horace, I just copied my .babelrc file from Horace into SPS.

PostCSS

I used to use SASS. However in the last couple of months that I used PostCSS for Horace it has grown on me. PostCSS is fast, and I love the control it gives me.

WebServer

Express

I have been using Express for Horace, and I intend to use Express for SPS as well. It is mature and everything that I will need works with Express out of the box: Static, GraphQL, and SocketIO. The entire gang is here.

GraphQL

I have tangled with GraphQL in the past and given up in defeat. Hopefully this time around I will be able to wrap my head around it (or rather around relay) better.

Other Stuff

JS Linting: ESlint

I decided to get serious about linting and spent a while reading the Airbnb JavaScript style guide. And then I incorporated most of their proposed lint rules into my own .eslintrc.json while skipping some. Particularly the ones requiring the use of ES6 modules. Personally I just like the syntax of CommonJS better (exports are at one place, not scattered throughout the source and const foo = require('bar') is more natural 'to me'). I would consider ES6 modules if they manage to figure out a better way than relative paths (or break compatibility with CommonJS) but in the meantime I'll stick with CommonJS.

Anyway the important thing is that I have linting in place 'before' I write any code.

Testing

I will be using Mocha and Istanbul on SPS. I have it setup for server side as well as client side code.

Configuration

There's this great little library called nconf that I have been using for config management with Horace. nconf picks up configuration from the command line, environment variables and config files.

Logging

Winston, with console and file transports.