aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/api/v1/repo/log.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-06 15:37:35 +0200
committerHampusM <hampus@hampusmat.com>2021-07-06 15:37:35 +0200
commit7b48039aa475b8c0b52b019f10fad66c7842d08b (patch)
treec3b0c1666ce74f0fb0b0f43a924a476b6164934a /packages/server/src/api/v1/repo/log.ts
parent10f0154f1f46881123ef3418beb0eced48bfb4b9 (diff)
API uses shared types
Diffstat (limited to 'packages/server/src/api/v1/repo/log.ts')
-rw-r--r--packages/server/src/api/v1/repo/log.ts31
1 files changed, 17 insertions, 14 deletions
diff --git a/packages/server/src/api/v1/repo/log.ts b/packages/server/src/api/v1/repo/log.ts
index aa6fa1a..8157696 100644
--- a/packages/server/src/api/v1/repo/log.ts
+++ b/packages/server/src/api/v1/repo/log.ts
@@ -3,10 +3,11 @@ import { Commit } from "../../../git/commit";
import { Patch } from "../../../git/patch";
import { Route } from "../../../fastify_types";
import { verifySHA } from "../../util";
+import { LogCommit as APILogCommit, Patch as APIPatch, Commit as APICommit } from "shared_types";
async function commitMap(commit: Commit) {
const stats = await commit.stats();
- return {
+ return <APILogCommit>{
id: commit.id,
author: {
name: commit.author.name,
@@ -21,7 +22,7 @@ async function commitMap(commit: Commit) {
}
async function patchMap(patch: Patch, index: number) {
- return {
+ return <APIPatch>{
additions: patch.additions,
deletions: patch.deletions,
from: patch.from,
@@ -57,19 +58,21 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do
const stats = await commit.stats();
+ const data: APICommit = {
+ message: commit.message,
+ author: {
+ name: commit.author.name,
+ email: commit.author.email
+ },
+ date: commit.date,
+ insertions: stats.insertions,
+ deletions: stats.deletions,
+ files_changed: stats.files_changed,
+ diff: await Promise.all((await (await commit.diff()).patches()).map(patchMap))
+ };
+
reply.send({
- data: {
- message: commit.message,
- author: {
- name: commit.author.name,
- email: commit.author.email
- },
- date: commit.date,
- insertions: stats.insertions,
- deletions: stats.deletions,
- files_changed: stats.files_changed,
- diff: await Promise.all((await (await commit.diff()).patches()).map(patchMap))
- }
+ data: data
});
}
});