aimedb: Enhance typing

This commit is contained in:
Tau
2019-04-28 19:52:44 -04:00
parent 8323e3ee7c
commit 27407d5387
2 changed files with 14 additions and 2 deletions

View File

@@ -1,8 +1,10 @@
import { Socket } from "net";
import { dispatch } from "./handler";
import { AimeRequest } from "./request";
import { setup } from "./pipeline";
export default async function aimedb(socket) {
export default async function aimedb(socket: Socket) {
console.log("Aimedb: Connection opened");
const { input, output } = setup(socket);

View File

@@ -1,13 +1,23 @@
import * as crypto from "crypto";
import { Socket } from "net";
import { pipeline } from "stream";
import { Decoder } from "./decoder";
import { Deframer } from "./frame";
import { Encoder } from "./encoder";
import { AimeRequest } from "./request";
import { AimeResponse } from "./response";
const K = Buffer.from("Copyright(C)SEGA", "utf8");
export function setup(socket) {
export interface Session {
input: AsyncIterable<AimeRequest>;
output: {
write(res: AimeResponse): void;
};
}
export function setup(socket: Socket): Session {
const input = pipeline(
socket,
crypto.createDecipheriv("aes-128-ecb", K, null).setAutoPadding(false),