Additional assorted layering cleanups
This commit is contained in:
@@ -3,8 +3,6 @@ import logger from "debug";
|
||||
import { Repositories } from "./repo";
|
||||
import * as Req from "./request";
|
||||
import * as Res from "./response";
|
||||
import { Transaction } from "../sql";
|
||||
import { SqlRepositories } from "./db";
|
||||
|
||||
const debug = logger("app:aimedb:ops");
|
||||
|
||||
@@ -103,12 +101,10 @@ function log(
|
||||
}
|
||||
|
||||
export async function dispatch(
|
||||
txn: Transaction,
|
||||
rep: Repositories,
|
||||
req: Req.AimeRequest,
|
||||
now: Date
|
||||
): Promise<Res.AimeResponse | undefined> {
|
||||
const rep = new SqlRepositories(txn);
|
||||
|
||||
switch (req.type) {
|
||||
case "hello":
|
||||
return hello(rep, req, now);
|
||||
|
||||
+5
-3
@@ -2,9 +2,9 @@ import logger from "debug";
|
||||
import { Socket } from "net";
|
||||
|
||||
import { dispatch } from "./handler";
|
||||
import { AimeRequest } from "./request";
|
||||
import { setup } from "./pipeline";
|
||||
import { DataSource } from "../sql/api";
|
||||
import { SqlRepositories } from "./sql";
|
||||
|
||||
const debug = logger("app:aimedb:session");
|
||||
|
||||
@@ -17,8 +17,10 @@ export default function aimedb(db: DataSource) {
|
||||
for await (const obj of input) {
|
||||
try {
|
||||
const now = new Date();
|
||||
const req = obj as AimeRequest;
|
||||
const res = await db.transaction(txn => dispatch(txn, req, now));
|
||||
const req = obj;
|
||||
const res = await db.transaction(txn =>
|
||||
dispatch(new SqlRepositories(txn), req, now)
|
||||
);
|
||||
|
||||
if (res === undefined) {
|
||||
debug("Closing connection");
|
||||
|
||||
Reference in New Issue
Block a user