Dashboard API explorer

/api/administrator/sessions-count (GET)

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

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

NodeJS source (view on github)

const dashboard = require('../../../../index.js')

module.exports = {
  get: async (req) => {
    const where = {
      appid: req.appid || global.appid
    }
    if (req.query && req.query.accountid) {
      where.accountid = req.query.accountid
    }
    return dashboard.Storage.Session.count({ where })
  }
}

Test source (view on github)

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

describe('/api/administrator/sessions-count', () => {
  describe('returns', () => {
    it('integer', async () => {
      const administrator = await TestHelper.createOwner()
      for (let i = 0, len = global.pageSize + 1; i < len; i++) {
        await TestHelper.createUser()
      }
      const req = TestHelper.createRequest('/api/administrator/sessions-count')
      req.account = administrator.account
      req.session = administrator.session
      req.filename = __filename
      req.saveResponse = true
      const result = await req.get()
      assert.strictEqual(result, global.pageSize + 2)
    })
  })
})