This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { isUndefined, omitBy } = require(`lodash/fp`); | |
const hash = require(`object-hash`); | |
class DataModel { | |
constructor(cache) { | |
if (isUndefined(cache)) { | |
throw new Error(`Data Models require a cache`); | |
} | |
this._cache = cache; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------ | |
// REST | |
// ------------ | |
// This is approxamately the function you would run to fetch the "Customer" | |
// resource for a REST endpoint. The HTTP stuff is normally be left to your | |
// framework so I'll leave that out. | |
app.serve("customer/:id", (urlParams) => { | |
return myORM.queryById(Customer, urlParams.id); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const logAllRoutes = function logAllRoutes(app) { | |
app._router.stack | |
.map((middleware) => { | |
// Return routes registered directly on the app | |
if (middleware.route) { return middleware.route } | |
// Return routes registered using Router middleware | |
if (middleware.name === 'router') { | |
return middleware.handle.stack.map(handler => handler.route); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
import {params, returns} from "llama/decorators"; | |
import types from from "llama/types"; | |
@params([ | |
["length", types.number.natural()], | |
["width", types.number.natural()], | |
["id", types.string.guid(), ``` | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dapibus tellus iaculis, |