Browse Source

Update torrent IPC in the torrent-rest service

dev
David Ludwig 4 years ago
parent
commit
c5e82e5acc
4 changed files with 5 additions and 15 deletions
  1. +0
    -10
      services/torrent-rest/src/services/TorrentIpc.ts
  2. +2
    -2
      services/torrent-rest/src/services/WebServer/middleware/torrent.ts
  3. +2
    -2
      services/torrent-rest/src/services/WebServer/routes/api.ts
  4. +1
    -1
      services/torrent-rest/src/services/index.ts

+ 0
- 10
services/torrent-rest/src/services/TorrentIpc.ts View File

@ -1,10 +0,0 @@
import { IpcClient } from "@autoplex-api/torrent";
import Application from "../Application";
export default class TorrentIpc extends IpcClient<Application>
{
/**
* The service name
*/
public readonly NAME = "Torrent Client";
}

+ 2
- 2
services/torrent-rest/src/services/WebServer/middleware/torrent.ts View File

@ -1,7 +1,7 @@
import { IpcClient as TorrentIpc } from "@autoplex-api/torrent";
import { IteratorNext, MiddlewareRequest, FastifyReply, Status, respond } from "@autoplex/webserver";
import { ISerializedTorrent } from "@autoplex-api/torrent";
import Application from "../../../Application";
import TorrentIpc from "../../TorrentIpc";
/**
* The parameter types for the auth middleware
@ -14,7 +14,7 @@ export interface ITorrentMiddleware {
* Ensure that a valid authentication token is provided
*/
export async function torrent<T extends ITorrentMiddleware>(request: MiddlewareRequest<T>, reply: FastifyReply, next: IteratorNext) {
let ipc = Application.instance().service<TorrentIpc>("Torrent Client");
let ipc = Application.instance().service<TorrentIpc>("Torrent");
let torrentId: string|undefined = (<any>request.params)["torrentId"];
if (torrentId === undefined) {
return respond(reply, Status.BadRequest);


+ 2
- 2
services/torrent-rest/src/services/WebServer/routes/api.ts View File

@ -1,7 +1,7 @@
import { IpcClient as TorrentIpc } from "@autoplex-api/torrent";
import { IpcConnectionError } from "@autoplex/ipc";
import { MiddlewareMethod, RouteRegisterFactory, Status, respond, } from "@autoplex/webserver";
import Application from "../../../Application";
import TorrentIpc from "../../TorrentIpc";
import { torrent } from "../middleware/torrent";
export default function register(factory: RouteRegisterFactory<MiddlewareMethod<void>, Application>,
@ -10,7 +10,7 @@ export default function register(factory: RouteRegisterFactory<MiddlewareMethod<
/**
* Fetch the torrent client instance
*/
const ipc = app.service<TorrentIpc>("Torrent Client");
const ipc = app.service<TorrentIpc>("Torrent");
/**
* Register API prefix


+ 1
- 1
services/torrent-rest/src/services/index.ts View File

@ -1,4 +1,4 @@
import TorrentIpc from "./TorrentIpc";
import { IpcClient as TorrentIpc } from "@autoplex-api/torrent";
import WebServer from "./WebServer/WebServer";
export {


Loading…
Cancel
Save