Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const ActionHero = require('actionhero')
const path = require('path')
const packageJSON = require(path.normalize(path.join(__dirname, '..', 'package.json')))
// These values are probably good starting points, but you should expect to tweak them for your application
const maxEventLoopDelay = process.env.eventLoopDelay || 10
const maxMemoryAlloted = process.env.maxMemoryAlloted || 200
const maxResqueQueueLength = process.env.maxResqueQueueLength || 1000
module.exports = class RandomNumber extends ActionHero.Action {
constructor () {
super()
this.name = 'status'
this.description = 'I will return some basic information about the API'
this.outputExample = {
id: '192.168.2.11',
actionheroVersion: '9.4.1',
uptime: 10469
}
}
async checkRam (data) {
const consumedMemoryMB = Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 100) / 100
data.response.consumedMemoryMB = consumedMemoryMB
if (consumedMemoryMB > maxMemoryAlloted) {
data.response.nodeStatus = data.connection.localize('Unhealthy')
'use strict'
const ActionHero = require('actionhero')
const path = require('path')
const packageJSON = require(path.normalize(path.join(__dirname, '..', 'package.json')))
// These values are probably good starting points, but you should expect to tweak them for your application
const maxEventLoopDelay = process.env.eventLoopDelay || 10
const maxMemoryAlloted = process.env.maxMemoryAlloted || 500
const maxResqueQueueLength = process.env.maxResqueQueueLength || 1000
module.exports = class RandomNumber extends ActionHero.Action {
constructor () {
super()
this.name = 'status'
this.description = 'I will return some basic information about the API'
this.outputExample = {
id: '192.168.2.11',
actionheroVersion: '9.4.1',
uptime: 10469
}
}
async checkRam (data) {
const consumedMemoryMB = Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 100) / 100
data.response.consumedMemoryMB = consumedMemoryMB
if (consumedMemoryMB > maxMemoryAlloted) {
data.response.nodeStatus = data.connection.localize('Unhealthy')
'use strict'
const ActionHero = require('actionhero')
module.exports = class ShowDocumentation extends ActionHero.Action {
constructor () {
super()
this.name = 'showDocumentation'
this.description = 'return API documentation'
}
outputExample () {
return {
documentation: {
cacheTest: {
1: {
name: 'cacheTest',
version: 1,
description: 'I will test the internal cache functions of the API',
inputs: {
key: {
'use strict'
const ActionHero = require('actionhero')
module.exports = class CreateChatRoom extends ActionHero.Action {
constructor () {
super()
this.name = 'createChatRoom'
this.description = 'I will create a chatroom with the given name'
this.inputs = {
name: {
required: true
}
}
}
async run ({ params, response }) {
const { chatRoom } = ActionHero.api
response.didCreate = await chatRoom.add(params.name)
}
}
'use strict'
const ActionHero = require('actionhero')
module.exports = class ShowDocumentation extends ActionHero.Action {
constructor () {
super()
this.name = 'showDocumentation'
this.description = 'return API documentation'
this.middleware = ['logged-in-session']
}
outputExample () {
return {
documentation: {
status: {
1: {
name: 'status',
version: 1,
description: 'I will return some basic information about the API',
inputs: {