mirror of
https://github.com/djhackersdev/minime.git
synced 2026-08-22 02:14:08 -05:00
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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -40,18 +40,14 @@ import { updateTeamMember } from "./updateTeamMember";
|
||||
import { updateTeamPoints } from "./updateTeamPoints";
|
||||
import { updateUiReport } from "./updateUiReport";
|
||||
import { updateUserLog } from "./updateUserLog";
|
||||
import { Repositories } from "../repo";
|
||||
import { Request } from "../request";
|
||||
import { Response } from "../response";
|
||||
import { Repositories } from "../repo";
|
||||
import { Transaction } from "../../sql";
|
||||
import { SqlRepositories } from "../db";
|
||||
|
||||
export async function dispatch(
|
||||
txn: Transaction,
|
||||
w: Repositories,
|
||||
req: Request
|
||||
): Promise<Response> {
|
||||
const w = new SqlRepositories(txn);
|
||||
|
||||
switch (req.type) {
|
||||
case "check_team_name_req":
|
||||
return checkTeamName(w, req);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Socket } from "net";
|
||||
import { dispatch } from "./handler";
|
||||
import { setup } from "./setup";
|
||||
import { DataSource } from "../sql";
|
||||
import { SqlRepositories } from "./sql";
|
||||
|
||||
const debug = logger("app:idz:session");
|
||||
|
||||
@@ -15,7 +16,11 @@ export default function idz(db: DataSource) {
|
||||
|
||||
try {
|
||||
for await (const req of input) {
|
||||
output.write(await db.transaction(txn => dispatch(txn, req)));
|
||||
const res = await db.transaction(txn =>
|
||||
dispatch(new SqlRepositories(txn), req)
|
||||
);
|
||||
|
||||
output.write(res);
|
||||
}
|
||||
} catch (e) {
|
||||
if (debug.enabled) {
|
||||
|
||||
Reference in New Issue
Block a user