'use strict';

const App = require('../index');

/**
 * @type {App}
 */
module.exports = new App({
    basedir: __dirname,
    express_port: 57355, // 0 for testing
    // express_user: 'test',
    // express_password: 'test',
    auto_routing: false,
    controller: {
        '/api': './controllers',
    },
    router: {
        '/admin/api': './router/api'
    },
    static: {
        '/admin': './public/admin',
        '/sandbox': './data/sandbox',
    },
    admin: {
        title: 'Test | Admin',
        baseUrl: '/admin',
        baseApiUrl: '/api/',
        changelog: __dirname + '/CHANGELOG.md', // TODO: solucionar para que no necesite dirname
        controllers: [
            'controllers/core.controller.js',
            'controllers/app.controller.js',
            'controllers/header.controller.js',
            'controllers/dashboard.controller.js',
            'controllers/rest.controller.js',
            'controllers/api-definition.controller.js',
            'controllers/profile.controller.js',
        ]
    },
    middleware: {
        '/api': [
            'hook'
        ]
    },
    api: {
        prefix: '/api',
        endpoints: [
            './api/*'
        ]
    },
    login: {
        enabled: true,
        initialize: true,
        store: 'datastore',
        loginUrl: '/admin/login',
        logoutUrl: '/admin/logout',
        loginEverywhere: false,
        users: [
            {
                key: 'admin',
                username: 'admin',
                password: 'admin',
                email: 'a@a.com',
                data: {}
            }
        ],
        tokens: [
            {
                key: 'default-token',
                user_key: 'admin',
                enabled: true,
                token: '20d6809f-d02d-4f6d-9164-c5e49e555a29',
                description: 'default token',
            }
        ]
    },
    cloud: {
        sql: {
            credentials: {
                credentials: {
                    options: {
                        host: '127.0.0.1',
                        port: '3306',
                        dialect: 'mysql',
                        retry: {match: 'ER_LOCK_DEADLOCK', max: 3},
                        logging: false,
                    },
                    username: 'root',
                    password: '',
                    database: 'test',
                }
            },
            models: './models/sql',
            namespace: 'test',
        },
        datastore: {
            models: './models/datastore',
            credentials: {
                projectId: process.env.CRED_PROJECTID,
                keyFilename: process.env.CRED_KEYFILE,
            },
            namespace: 'test',
            partition: false,
        }
    },
    cluster: {
        enabled: true,
        type: 'master',
    }
});