const express = require('express')
const router = express.Router()

const api = require('./controller')
const auth = require('../auth/controller')

// -----------------------------------------------------------------------------
// ADMINISTRATIVE
// -----------------------------------------------------------------------------

// Create super account, only once
router.post('/actions/setup', api.seedSuperAccounts)
// Seed initial accounts
router.post('/actions/seed', auth.isAdmin, api.seedAccounts)
// Delete all accounts
router.delete('/actions/delete', auth.isAdmin, api.deleteAccounts)
router.delete('/actions/empty', [auth.isWithAPIKey, auth.isTest], api.deleteAccounts)
// Get all accounts
router.get('/', auth.isAdmin, api.getAccounts)

// -----------------------------------------------------------------------------
// PUBLIC
// -----------------------------------------------------------------------------

// Get account by accountId
router.get('/:accountId', auth.isAuthenticated, api.getAccountProfileById)

// -----------------------------------------------------------------------------

module.exports = router

@@ -68,18 +68,19 @@
 %0Aconst a
-pi
+uth
  = requi
@@ -84,16 +84,25 @@
 quire('.
+./../auth
 /control
@@ -106,35 +106,34 @@
 roller')%0Aconst a
-uth
+pi
  = require('../a
@@ -129,22 +129,16 @@
 quire('.
-./auth
 /control
@@ -389,16 +389,51 @@
 /setup',
+ %5Bauth.isWithAPIKey, auth.isSetup%5D,
  api.see
@@ -502,28 +502,49 @@
 /seed', 
+%5B
 auth.is
-Admin
+WithAPIKey, auth.isSetup%5D
 , api.se
@@ -611,28 +611,49 @@
 elete', 
+%5B
 auth.is
-Admin
+WithAPIKey, auth.isSetup%5D
 , api.de
@@ -752,16 +752,17 @@
 counts)%0A
+%0A
 // Get a

Use auth.isSetup with key for administrative setup