aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/git/http.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-26 23:56:53 +0200
committerHampusM <hampus@hampusmat.com>2021-07-26 23:56:53 +0200
commit09ff261f156a8599d45c1496fe246ded6e035191 (patch)
tree306f79709da372b562eca70d356fa25afcde1f95 /packages/server/src/git/http.ts
parentc575df758b269db8e05c597d5870e948771d4c2b (diff)
Added backend TSDoc/JSDoc comments & refactored a tiny bit
Diffstat (limited to 'packages/server/src/git/http.ts')
-rw-r--r--packages/server/src/git/http.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/server/src/git/http.ts b/packages/server/src/git/http.ts
index 36bae04..c2654e7 100644
--- a/packages/server/src/git/http.ts
+++ b/packages/server/src/git/http.ts
@@ -8,12 +8,25 @@ export interface Request extends FastifyRequest {
params: Route["Params"],
}
+/**
+ * Write the first part of a reference discovery reply
+ *
+ * @param service - The git service to write as
+ * @param reply - A Fastify reply
+ */
function writeRefDiscoveryFirstLine(service: string, reply: FastifyReply) {
const s = "# service=" + service + "\n";
const n = (4 + s.length).toString(16);
reply.raw.write(Buffer.from((Array(4 - n.length + 1).join("0") + n + s) + "0000"));
}
+/**
+ * Connect to the Git HTTP backend
+ *
+ * @param repository - The repository to use
+ * @param req - A Fastify request
+ * @param reply - A Fastify reply
+ */
export function connect(repository: Repository, req: Request, reply: FastifyReply): void {
const parsed_url = new URL(`${req.protocol}://${req.hostname}${req.url.replace(req.params.repo, repository.name.short)}`);