A mistate is a Javascript data structure with a schema, underlying immutable data structure, lensing, and efficient subscriber abilities.
The schema format is the same as GraphQL.
Here's an example:
| var good = {a: {b: {c: 1}}} | |
| console.log(new Maybe(good).bind(t=>t.a).bind(t=>t.b).bind(t=>t.c).getOrElse(2)) | |
| var bad = {a: 3} | |
| console.log(new Maybe(bad).bind(t=>t.a).bind(t=>t.b).bind(t=>t.c).getOrElse(2)) |
A mistate is a Javascript data structure with a schema, underlying immutable data structure, lensing, and efficient subscriber abilities.
The schema format is the same as GraphQL.
Here's an example:
| start :: ApiGateway -> Request -> Response | |
| create :: forall i, o. | |
| { | |
| method, | |
| path, | |
| intReq: Async (HTTPRequest -> i), | |
| lambda: Async (i -> Tuple o Status), | |
| intRes: Status -> o -> Async HTTPResponse | |
| } -> ApiGateway | |
| -- problems: does o differ per status but need to be synced between 7/8? |
| 1. Choose your boundary | |
| 2. Identify state | |
| 3. Test *just* the boundary | |
| 4. Any test that will be maintained (non-TDD) should have a positive and negative test | |
| 5. Unit tests can be thrown away at will | |
| 6. DRY/inheritance is usually bad in test code, especially if stateful | |
| 7. Try to colocate data and code as much as possible | |
| 8. Make randomness and time explicit | |
| 9. It’s best to write tests FIRST |
| let set = (cache, val, k, ...rest) => { | |
| if (rest && rest.length) { | |
| if (!cache.has(k)) { | |
| cache.set(k, new Map()); | |
| } | |
| set(cache.get(k), val, ...rest); | |
| } else { | |
| cache.set(k, val); | |
| } | |
| }; |
| const choice = (decision) => { | |
| let yes = () => {}; | |
| let no = () => {}; | |
| const a = { | |
| yes: (f) => { yes = f; return a; }, | |
| no: (f) => { no = f; return a; }, | |
| decide: () => { | |
| const next = decision() ? yes() : no(); | |
| return next.decide ? next.decide() : next; | |
| } |
| const a = { | |
| foo: "bar", | |
| beep: { | |
| boop: 1, | |
| }, | |
| baz: [ | |
| true, | |
| ] | |
| }; |
| ☐ Put JWT in a cookie | |
| ☐ HTTPOnly cookie | |
| ☐ Secure cookie | |
| ☐ Domain w/ a subdomain (never root) | |
| ☐ No authorization in the JWT body (look it up serverside ya lazy asses) | |
| ☐ Userid in cookie should NOT exist anywhere but auth service | |
| ☐ Short window ( < 15 min) for JWT authentication token | |
| ☐ Ability to deauthorize a refresh token chain serverside (but long life on a refresh token is OK) | |
| ☐ Ability to monitor requests by refresh token chain |
| interface FooId extends String { | |
| _fooIdBrand: string; | |
| }; | |
| export interface Foo { | |
| id: FooId; | |
| color: 'yellow'; | |
| isAwesome: true; | |
| } | |
| interface BarId extends String { |
| Worker information | |
| hostname: e493aab3-9ebb-4ff3-bf71-74d0216e5c37@4740.wjb-1 | |
| version: v3.6.0 https://github.com/travis-ci/worker/tree/170b2a0bb43234479fd1911ba9e4dbcc36dadfad | |
| instance: 2d2c786d-0537-48f2-96f1-2eb3fa4a1976 travis-ci-macos10.12-xcode8.3-1507738863 (via amqp) | |
| startup: 1m6.709206302s | |
| Download from https://build.travis-ci.com/filter/redirect_io.rb failed. Trying https://build.travis-ci.com/filter/redirect_io.rb ... | |
| ruby: No such file or directory -- /Users/travis/filter.rb (LoadError) |