create public build endpoint
This commit is contained in:
17
src/DB.ts
17
src/DB.ts
@@ -25,6 +25,7 @@ interface Build {
|
||||
status: Status;
|
||||
pid?: number;
|
||||
sqid?: string;
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
interface User {
|
||||
@@ -105,6 +106,10 @@ class DB {
|
||||
pid: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true
|
||||
},
|
||||
uuid: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true
|
||||
}
|
||||
});
|
||||
|
||||
@@ -182,13 +187,14 @@ class DB {
|
||||
return user.id;
|
||||
}
|
||||
|
||||
public async createBuild(repo: string, commit: string, patch: string, distro: string, dependencies: string, author: string): Promise<number> {
|
||||
public async createBuild(repo: string, commit: string, patch: string, distro: string, dependencies: string, author: string, uuid: string): Promise<number> {
|
||||
const buildRec = await this.build.create({
|
||||
repo,
|
||||
commit: commit || null,
|
||||
patch: patch || null,
|
||||
distro,
|
||||
dependencies,
|
||||
uuid,
|
||||
userId: author || '-1'
|
||||
});
|
||||
return buildRec.id;
|
||||
@@ -241,6 +247,15 @@ class DB {
|
||||
});
|
||||
}
|
||||
|
||||
public async getBuildByUuid(uuid: string): Promise<Build> {
|
||||
return await this.build.findOne({
|
||||
where: {
|
||||
uuid
|
||||
},
|
||||
include: this.user
|
||||
});
|
||||
}
|
||||
|
||||
public async getBuilds(): Promise<Build[]> {
|
||||
return await this.build.findAll({
|
||||
attributes: SELECT,
|
||||
|
||||
Reference in New Issue
Block a user