# Starter Kit Technology Choices Module format - Everyone likes ES6 Database - Everyone likes Postgres ## Database adapter and ORM - I used Sequelize a tiny bit and don't completely hate it - Sequelize database adapter object is self-contained, not tied to global scope, so you can have as many as you want ## Database migrations Top options: - Sequelize - Existing framework used by Phrebar projects ### Phrebar upgrader - Records upgrades by name and hash in a table in the database - Can look back and see exactly what upgrades were run - Allows multiple directories of upgrades that can be run selectively - upgrades/ - Run everywhere - test-data/ - Included for upgrade scripts - dev-data/ - Extra data for devs to mess with - Can run SQL files, PHP scripts - Uses project's database connection settings - Just needs a database driver ### Sequelize migrations - Scripts are Node modules with 'up', 'down' functions that each take a query interface and return a promise Documentation left me with some questions: - How does it know what order to run migrations? - Can we run only a subset (e.g. include 'test-data' or not)? - How does this track current version? - Any way to see all migrations that have been run? ### Hybrid approach? e.g. Use Phrebar scheme for defining and tracking upgrades if Sequelize is missing some of the features we like, but use Sequelize migration modules. ## Unit testing I would like something simple that can run basic self-contained unit tests in the browser or in Node. Tests should just be functions that return promises of their results, maybe taking some kind of application context as a parameter. Something like export tests:{ [testName]: (ctx:ApplicationContext) => Promise } = { ... } The promise can return a TestResult that indicates no failures or one that indicates failures, potentially including other information either way, or it can be rejected, which is treated as a failure/error. ## Automation approach Requirements: - Single place to define how to build everything - Automatic or at least easy way to avoid rebuilding things that are already up-to-date, a la Make - Works on any environment where Node works ### RunJS - https://github.com/pawelgalazka/runjs - basically a bunch of named JavaScript functions ### Fake Makefile - http://kvz.io/blog/2016/02/18/a-universal-makefile-for-javascript/ - Delegates to npm scripts ## Transpiler Requirements: - Static type checking - Static null checks - Can compile to both AMD (for the browser) and CJS (for the server) (or potentially to ES6 modules) I've only used TypeScript. Looking at this to form opinions on Flow: http://michalzalecki.com/typescript-vs-flow/ Seems to lean a bit towards TS for how I like to use it. ### Typescript - In my experience TS is very good at caching mistakes at compile time - Definitely native JS; installs as an NPM module - Self-contained; no need for Babel or other transpilation steps - VS code supports natively - Supports public/protected/private members - strictNullChecks - noImplicitAny ### Babel+Flow - Is flow native JS now? Used to be OCAML. - ??? ## HTTP Library Requirements: - Model request handlers as (request:HTTPRequest) => Promise Fetch API fits that constraint and is going to be standard, so may as well use it. Nothing prevents us from making our own fetch function implementations using the Fetch API Request/Response types.