Skip to main content

Reaction

This is used in the file of a Trigger.

File

Write

FieldTypeRequiredDefaultDescription
filestring✔️none
datastring✔️none
Return

void

Example
const reaction = async (event) => {
file.write("monfichier.txt", data)
}

Read

FieldTypeRequiredDefaultDescription
filestring✔️none
Return

string

Example
const reaction = async (event) => {
const content = file.read("monfichier.txt")
console.log(content)
}

Append

FieldTypeRequiredDefaultDescription
filestring✔️none
datastring✔️none
Return

void

Example
const reaction = async (event) => {
file.append("monfichier.txt", "\ncoucou")
}

Temp Variable

Get

FieldTypeRequiredDefaultDescription
keystring✔️none
Return

Return Promise<any>.

Example
const reaction = async (event) => {
const valeur = temp.get("waza")
console.log({ valeur })
}

Set

FieldTypeRequiredDefaultDescription
keystring✔️none
dataany✔️none
Return

Return the value set

Example
const reaction = async (event) => {
const valeur = temp.set("waza", "test")
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = temp.set("waza", 42)
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = temp.set("waza", { test: 42 })
console.log({ valeur })
}

Cache Variable

Get

FieldTypeRequiredDefaultDescription
keystring✔️none
fileNamestringnone
Return

Return Promise<any>.

Example
const reaction = async (event) => {
const valeur = cache.get("waza")
console.log({ valeur })
}

Set

FieldTypeRequiredDefaultDescription
keystring✔️none
dataany✔️none
fileNamestringnone
Return

Return the value set

Example
const reaction = async (event) => {
const valeur = cache.set("waza", "test")
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = cache.set("waza", 42)
console.log({ valeur })
}
const reaction = async (event) => {
const valeur = cache.set("waza", { test: 42 })
console.log({ valeur })
}

Utils

Sleep

FieldTypeRequiredDefaultDescription
msnumber✔️noneA number
Return

Return Promise<void>.

Example
const reaction = async (event) => {
await sleep(5000)
}

newEvent

FieldTypeRequiredDefaultDescription
objectobject✔️noneYour event data !
Return

void

Example
const reaction = async (event) => {
newEvent('my-event', {
data: 42
})
}

Http Request

axios

alias for axios (0.21.4) npm package

const reaction = async (event) => {
const {data} = axios.get("")
console.log(data)
}

Constants

SEP

Folder separator

const reaction = async (event) => {
console.log(SEP)

}

PATH_JOIN

path.join nodejs alias

const reaction = async (event) => {
console.log(PATH_JOIN('resources', 'fart.mp3'))

}

WORKSPACE

WORKSPACE ....

const reaction = async (event) => {
console.log(WORKSPACE)

}

RESOURCES

RESOURCES ....

const reaction = async (event) => {
console.log(RESOURCES)

}

Debug

Log

const reaction = async (event) => {
console.log('my-event', {
data: 42
})
}

OR

const reaction = async (event) => {
log('my-event', {
data: 42
})
}

Info

const reaction = async (event) => {
console.info('my-event', {
data: 42
})
}

OR

const reaction = async (event) => {
info('my-event', {
data: 42
})
}

Warn

const reaction = async (event) => {
console.warn('my-event', {
data: 42
})
}

OR

const reaction = async (event) => {
warn('my-event', {
data: 42
})
}

Error

const reaction = async (event) => {
console.error('my-event', {
data: 42
})
}

OR

const reaction = async (event) => {
error('my-event', {
data: 42
})
}

Debug

const reaction = async (event) => {
console.debug('my-event', {
data: 42
})
}

OR

const reaction = async (event) => {
debug('my-event', {
data: 42
})
}