commit
d2ed53b946
@ -117,7 +117,7 @@ export async function getImages(request: FastifyRequest<GetImages>) {
|
|||||||
export async function cleanupUnconfiguredApplications(request: FastifyRequest<any>) {
|
export async function cleanupUnconfiguredApplications(request: FastifyRequest<any>) {
|
||||||
try {
|
try {
|
||||||
const teamId = request.user.teamId;
|
const teamId = request.user.teamId;
|
||||||
let applications = await prisma.application.findMany({
|
const applications = await prisma.application.findMany({
|
||||||
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } },
|
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } },
|
||||||
include: { settings: true, destinationDocker: true, teams: true }
|
include: { settings: true, destinationDocker: true, teams: true }
|
||||||
});
|
});
|
||||||
@ -167,7 +167,7 @@ export async function getApplicationStatus(request: FastifyRequest<OnlyId>) {
|
|||||||
try {
|
try {
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const { teamId } = request.user;
|
const { teamId } = request.user;
|
||||||
let payload = [];
|
const payload = [];
|
||||||
const application: any = await getApplicationFromDB(id, teamId);
|
const application: any = await getApplicationFromDB(id, teamId);
|
||||||
if (application?.destinationDockerId) {
|
if (application?.destinationDockerId) {
|
||||||
if (application.buildPack === 'compose') {
|
if (application.buildPack === 'compose') {
|
||||||
@ -565,7 +565,7 @@ export async function restartApplication(
|
|||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const { imageId = null } = request.body;
|
const { imageId = null } = request.body;
|
||||||
const { teamId } = request.user;
|
const { teamId } = request.user;
|
||||||
let application: any = await getApplicationFromDB(id, teamId);
|
const application: any = await getApplicationFromDB(id, teamId);
|
||||||
if (application?.destinationDockerId) {
|
if (application?.destinationDockerId) {
|
||||||
const buildId = cuid();
|
const buildId = cuid();
|
||||||
const { id: dockerId, network } = application.destinationDocker;
|
const { id: dockerId, network } = application.destinationDocker;
|
||||||
@ -737,7 +737,7 @@ export async function deleteApplication(
|
|||||||
where: { id },
|
where: { id },
|
||||||
include: { destinationDocker: true, teams: true }
|
include: { destinationDocker: true, teams: true }
|
||||||
});
|
});
|
||||||
if (!application.teams.find((team) => team.id === teamId) || teamId !== '0') {
|
if (teamId === '0' || !application.teams.some((team) => team.id === teamId)) {
|
||||||
throw { status: 403, message: 'You are not allowed to delete this application.' };
|
throw { status: 403, message: 'You are not allowed to delete this application.' };
|
||||||
}
|
}
|
||||||
if (application?.destinationDocker?.id && application.destinationDocker?.network) {
|
if (application?.destinationDocker?.id && application.destinationDocker?.network) {
|
||||||
@ -1377,7 +1377,7 @@ export async function restartPreview(
|
|||||||
try {
|
try {
|
||||||
const { id, pullmergeRequestId } = request.params;
|
const { id, pullmergeRequestId } = request.params;
|
||||||
const { teamId } = request.user;
|
const { teamId } = request.user;
|
||||||
let application: any = await getApplicationFromDB(id, teamId);
|
const application: any = await getApplicationFromDB(id, teamId);
|
||||||
if (application?.destinationDockerId) {
|
if (application?.destinationDockerId) {
|
||||||
const buildId = cuid();
|
const buildId = cuid();
|
||||||
const { id: dockerId, network } = application.destinationDocker;
|
const { id: dockerId, network } = application.destinationDocker;
|
||||||
@ -1692,7 +1692,7 @@ export async function getBuildIdLogs(request: FastifyRequest<GetBuildIdLogs>) {
|
|||||||
try {
|
try {
|
||||||
await fs.stat(file);
|
await fs.stat(file);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let logs = await prisma.buildLog.findMany({
|
const logs = await prisma.buildLog.findMany({
|
||||||
where: { buildId, time: { gt: sequence } },
|
where: { buildId, time: { gt: sequence } },
|
||||||
orderBy: { time: 'asc' }
|
orderBy: { time: 'asc' }
|
||||||
});
|
});
|
||||||
@ -1708,9 +1708,9 @@ export async function getBuildIdLogs(request: FastifyRequest<GetBuildIdLogs>) {
|
|||||||
status: data?.status || 'queued'
|
status: data?.status || 'queued'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let fileLogs = (await fs.readFile(file)).toString();
|
const fileLogs = (await fs.readFile(file)).toString();
|
||||||
let decryptedLogs = await csv({ noheader: true }).fromString(fileLogs);
|
const decryptedLogs = await csv({ noheader: true }).fromString(fileLogs);
|
||||||
let logs = decryptedLogs
|
const logs = decryptedLogs
|
||||||
.map((log) => {
|
.map((log) => {
|
||||||
const parsed = {
|
const parsed = {
|
||||||
time: log['field1'],
|
time: log['field1'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user