33 lines
728 B
TypeScript
33 lines
728 B
TypeScript
import { Application, ApplicationOutput } from "../types/components"
|
|
|
|
function application(body: any): Application {
|
|
let app = body?.application ? body.application : body
|
|
return {
|
|
_id: app.appId,
|
|
name: app.name,
|
|
url: app.url,
|
|
status: app.status,
|
|
createdAt: app.createdAt,
|
|
updatedAt: app.updatedAt,
|
|
version: app.version,
|
|
tenantId: app.tenantId,
|
|
lockedBy: app.lockedBy,
|
|
}
|
|
}
|
|
|
|
function mapApplication(ctx: any): ApplicationOutput {
|
|
return {
|
|
data: application(ctx.body),
|
|
}
|
|
}
|
|
|
|
function mapApplications(ctx: any): { data: Application[] } {
|
|
const apps = ctx.body.map((body: any) => application(body))
|
|
return { data: apps }
|
|
}
|
|
|
|
export default {
|
|
mapApplication,
|
|
mapApplications,
|
|
}
|