This document is a short description of the monorepo setup that I came up for a few different smaller projects in the last 8 months or so.
/
services/
product/
import Koa from "koa" | |
import * as KoaHAL from "$new-hal-koa-package" | |
import { api, Users } from "./hal" | |
const app = new Koa() | |
const koaRouter = KoaHAL.Router(api, router => { | |
// GET /users | |
router.get(Users, async ctx => { | |
const users = await queryAllUsers() |
import { Responses as PublisherAPIResponses } from "@satoshipay/publisher-service-api" | |
import axios from "axios" | |
import { URL } from "url" | |
import config from "../config" | |
export async function getPublisherById (id: string) { | |
const url = new URL(`/${id}`, config.publisherServiceUrl).toString() | |
return await axios.get(url) as PublisherAPIResponses["GET /*"] | |
} |
import { createApp, respond, route } from "koax" | |
import pkg from "../package.json" | |
const app = createApp() | |
app.get("/", async () => { | |
const body = { | |
name: pkg.name, | |
version: pkg.version | |
} |
I hereby claim:
To claim this, I am signing this object:
/* | |
* Description: | |
* | |
* There are times when we want to re-use some data created/derived in a middleware later in a route handler. | |
* | |
* The default Koa way of doing so would be using `context.state`. Unfortunately `context.state` is hard to type and | |
* quite implicit, since it's an object shared and potentially mutated by all middlewares and the route handler. | |
*/ | |
/* |
let lastLoggingTime = Date.now(); | |
function logUpdate (componentName, update, stateBefore, stateAfter, stack) { | |
const msSinceLastPrint = Date.now() - lastLoggingTime; | |
console.groupCollapsed( | |
`%c<${componentName}> setState: %o %c%s`, | |
"color: #5080ff", | |
update, | |
"color: #808080", |
type Arguments<T> = [T] extends [(...args: infer U) => any] | |
? U | |
: [T] extends [void] ? [] : [T] | |
/** | |
* Type-safe event emitter. | |
* | |
* Use it as: | |
* | |
* interface MyEvents { |
SEP-0007 introduced a standard for payment requests (basically templated transactions) on Stellar. In order to provide a smooth user experience when working with multi-signature accounts, wallets need to be able to send each other realtime payment requests.
That requires a new kind of service in the Stellar eco system: A multi-signature coordination service.