module.exports = exports = {

    prefix: '/api/v1/db',

    middleware: [],

    get: {
        // Get the database ref node config for the specified database
        '/:PageId/:NodeId/get/:DatabaseId': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'view' }],
            'controller::api:v1:FormDatabase.get_config',
        ],

        // Get the column config records for the specified database
        '/:PageId/:NodeId/get/:DatabaseId/columns': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'view' }],
            'controller::api:v1:FormDatabase.get_columns',
        ],

        // Get the row records for the specified database
        '/:PageId/:NodeId/get/:DatabaseId/data': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'view' }],
            'controller::api:v1:FormDatabase.get_data',
        ],
    },

    post: {
        // Create a new database ref config
        '/:PageId/:NodeId/create': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'update' }],
            'controller::api:v1:FormDatabase.create_new',
        ],

        // Set the column configs for a database ref
        '/:PageId/:NodeId/set/:DatabaseId/columns': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'update' }],
            'controller::api:v1:FormDatabase.set_columns',
        ],

        // Set the database name
        '/:PageId/:NodeId/set/:DatabaseId/Name': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'update' }],
            'controller::api:v1:FormDatabase.set_name',
        ],

        // Delete the specified database ref
        '/:PageId/:NodeId/drop/:DatabaseId': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'update' }],
            'controller::api:v1:FormDatabase.drop_database',
        ],

        // Set the row data for the specified database ref
        '/:PageId/:NodeId/set/:DatabaseId/data': [
            'middleware::auth:ApiRoute',
            ['middleware::api:DataInjection', { access_level: 'update' }],
            'controller::api:v1:FormDatabase.set_data',
        ],
    },
}
