"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const describeView_1 = require("./server/describeView");
const socketView_1 = require("./server/socketView");
const configView_1 = require("./server/configView");
const path = require("path");
const express = require("express");
function init(config, options) {
    const describePath = (options && options.path) ? options.path : '/describe';
    config.run('express', {
        onStart: (instance) => {
            var options = {
                //dotfiles: 'ignore',
                etag: true,
                extensions: ['htm', 'html', 'js', 'js.map', 'css'],
                maxAge: '1d',
                redirect: false,
                setHeaders: function (res, path, stat) {
                    res.set('x-timestamp', Date.now());
                }
            };
            const clientDir = path.resolve(path.join(__dirname, './client'));
            instance.use(describePath, express.static(clientDir, options));
            const methodClientPath = path.join(process.cwd(), 'node_modules', '@methodus/client', 'dist');
            instance.use(`${describePath}/scripts/`, express.static(methodClientPath, options));
            // var proxy = require('http-proxy-middleware');
            // console.log(config);
            // // proxy middleware options
            // var proxyOptions = {
            //     target: 'http://localhost:2065', // target host
            //     changeOrigin: true,               // needed for virtual hosted sites
            //     ws: true,                         // proxy websockets
            //     pathRewrite: {
            //         '^/describeproxy': '/describe',     // rewrite path
            //         // '^/api/remove/path': '/path'           // remove base path
            //     },
            //     // router: {
            //     //     // when request.headers.host == 'dev.localhost:3000',
            //     //     // override target 'http://www.example.org' to 'http://localhost:8000'
            //     //     'dev.localhost:3000': 'http://localhost:2065'
            //     // }
            // };
            // // create the proxy (without context)
            // var exampleProxy = proxy(proxyOptions);
            // instance.use('/describeproxy', exampleProxy);
        }
    });
    config.run('socketio', { nsp: describePath });
    config.use(describeView_1.DescribeView, 'Local', 'express');
    config.use(configView_1.ConfigView, 'Local', 'express');
    config.use(socketView_1.SocketView, 'Local', 'socketio');
    // config.use(Config, MethodType.Local, ServerType.Express, process.env.CONFIGURATIO_SERVICE);
    return config;
}
exports.init = init;
//# sourceMappingURL=index.js.map