Dashboard API explorer

/api/administrator/administrator-accounts-count (GET)

Account information like email addresses is generated with faker-js it is not real user information.

await global.api.administrator.AdministratorAccountsCount.get(req)

NodeJS source (view on github)

const dashboard = require('../../../../index.js')
const { Op } = require('sequelize')

module.exports = {
  get: async (req) => {
    return dashboard.Storage.Account.count({
      where: {
        administratorSince: {
          [Op.gt]: 0
        },
        appid: req.appid || global.appid
      }
    })
  }
}

Test source (view on github)

/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../test-helper.js')

describe('/api/administrator/administrator-accounts-count', () => {
  describe('returns', () => {
    it('integer', async () => {
      const owner = await TestHelper.createOwner()
      await TestHelper.createAdministrator(owner)
      const req = TestHelper.createRequest('/api/administrator/administrator-accounts-count')
      req.account = owner.account
      req.session = owner.session
      req.filename = __filename
      req.saveResponse = true
      const result = await req.get()
      assert.strictEqual(result, global.pageSize)
    })
  })
})