import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import ConnectRoute from 'connect-route';

import '../imports/api/methods/worklist.js';
import '../imports/api/methods/changePassword.js';

import '../imports/api/methods/brands.js';
import '../imports/api/methods/hisLink.js';
import '../imports/api/methods/clients.js';
import '../imports/api/methods/devicemap.js';
import '../imports/api/methods/users.js';
import '../imports/api/methods/translitdb.js';


import '../imports/api/server/publications/worklist.js';

import '../imports/api/server/publications/hislink.js';
import '../imports/api/server/publications/brands.js';
import '../imports/api/server/publications/clients.js';
import '../imports/api/server/publications/devicemap.js';
import '../imports/api/server/publications/users.js';
import '../imports/api/server/publications/worklist4hislink.js';
import '../imports/api/server/publications/translitdbuploads.js';
import '../imports/api/server/publications/transliterationdb.js';


import { Accounts } from "meteor/accounts-base";







Meteor.startup(() => {

    let marcoUser = Meteor.users.findOne({ username: "marcoadmin" });
    if (marcoUser == undefined || marcoUser == null)
        Accounts.createUser({
            username: 'marcoadmin',
            password: 'sysAdmin4.21',
            profile: {
                "language": {
                    "name": "English",
                    "alias": "en"
                },
                "fullName": "marcoadmin",
                "picture": "/img/empty.png"
            }
        });

    Meteor.users.deny({ update: () => true });

});

function onRoute(req, res, next) {
    res.writeHead(307, { 'Location': "/landing.html" });
    res.end();
}


const middleWare = ConnectRoute(function(router) {
    router.get('/', onRoute);

});

WebApp.connectHandlers
    .use(middleWare);