1 Star 0 Fork 0

麦舒/haoyi-shop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 8.03 KB
一键复制 编辑 原始数据 按行查看 历史
麦舒 提交于 2019-12-20 16:32 . update
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const maishu_node_auth_1 = require("maishu-node-auth");
const maishu_image_service_1 = require("maishu-image-service");
const merchant_1 = require("./merchant");
const shop_1 = require("./shop");
const weixin_1 = require("./weixin");
const member_1 = require("./member");
const account_1 = require("./account");
const path = require("path");
function start(config) {
const gatewayPort = config.gatewayPort;
const gatewayBindIP = config.gatewayBindIP;
const gateway = gatewayBindIP ? `${gatewayBindIP}:${gatewayPort}` : `127.0.0.1:${gatewayPort}`;
const permissionStationPort = gatewayPort + 100;
const portalStationPort = gatewayPort + 200;
const merchantStationPort = gatewayPort + 300;
const shopStationPort = gatewayPort + 400;
const imageStationPort = gatewayPort + 500;
const weixinStationPort = gatewayPort + 600;
const memberStationPort = gatewayPort + 700;
const accountStationPort = gatewayPort + 800;
const imageStation = config.gatewayBindIP ? `${gatewayBindIP}:${imageStationPort}` : `127.0.0.1:${imageStationPort}`;
//===========================================
let gatewayStationSettings = {
port: gatewayPort,
bindIP: gatewayBindIP,
db: {
user: config.db_user,
password: config.db_password,
database: "node_auth_gateway",
host: config.db_host,
port: config.db_port,
charset: "utf8",
},
logLevel: "all",
virtualPaths: {
node_modules: path.join(__dirname, "node_modules"),
},
proxy: {
'/AdminSite/(\\S+)': `http://${config.target_host}:9000/Admin/$1`,
'/AdminStock/(\\S+)': `http://${config.target_host}:9005/Admin/$1`,
'/AdminShop/(\\S+)': `http://${config.target_host}:9010/Admin/$1`,
'/AdminMember/(\\S+)': `http://${config.target_host}:9020/Admin/$1`,
'/AdminWeiXin/(\\S+)': `http://${config.target_host}:9030/Admin/$1`,
'/AdminAccount/(\\S+)': `http://${config.target_host}:9035/Admin/$1`,
'/UserSite/(\\S+)': `http://${config.target_host}:9000/User/$1`,
'/UserStock/(\\S+)': `http://${config.target_host}:9005/User/$1`,
'/UserShop/(\\S+)': `http://${config.target_host}:9010/User/$1`,
'/UserMember/(\\S+)': `http://${config.target_host}:9020/User/$1`,
'/UserWeiXin/(\\S+)': `http://${config.target_host}:9030/User/$1`,
'/UserAccount/(\\S+)': `http://${config.target_host}:9035/User/$1`,
"^/Images/Editor/(\\S+)": "http://web.alinq.cn/store2/Images/Editor/$1",
"^/image/(\\S+)": `http://${imageStation}/$1`,
},
headers: {
'Content-Type': 'application/json;charset=utf-8',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Headers': '*'
},
permissions: {
"/": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
// "/socket.io/*": { roleIds: [roleIds.anonymousRoleId] },
// "/socket*": { roleIds: [roleIds.anonymousRoleId] },
"*.js": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"*.html": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"*.css": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"*.less": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"*.jpg": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"*.png": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"*.woff": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"*.map": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/favicon.ico": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/auth/user/login": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/auth/station/list": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/auth/station/register": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/AdminMember/*": { roleIds: [merchant_1.merchantRoleId] },
"/AdminShop/*": { roleIds: [merchant_1.merchantRoleId] },
"/AdminStock/*": { roleIds: [merchant_1.merchantRoleId] },
"/AdminAccount/*": { roleIds: [merchant_1.merchantRoleId] },
"/AdminWeiXin/*": { roleIds: [merchant_1.merchantRoleId] },
"/UserMember/*": { roleIds: [merchant_1.merchantRoleId, maishu_node_auth_1.roleIds.normalUser] },
"/UserShop/*": { roleIds: [merchant_1.merchantRoleId, maishu_node_auth_1.roleIds.normalUser] },
"/UserStock/*": { roleIds: [merchant_1.merchantRoleId, maishu_node_auth_1.roleIds.normalUser] },
"/Images/Editor/*": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/portal/*": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/image/*": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/*/websiteConfig": { roleIds: [maishu_node_auth_1.roleIds.anonymous] },
"/*/clientFiles": { roleIds: [maishu_node_auth_1.roleIds.anonymous] }
},
};
// permissions[`${stationPath}websiteConfig`] = { roleIds: [roleIds.anonymous] };
// permissions[`${stationPath}clientFiles`] = { roleIds: [roleIds.anonymous] };
let permissionStationSettings = {
port: permissionStationPort,
gateway,
db: {
user: config.db_user,
password: config.db_password,
database: "node_auth_permission",
host: config.db_host,
port: config.db_port,
charset: "utf8",
},
virtualPaths: {
"node_modules": path.join(__dirname, "node_modules")
}
};
let portalStationSettings = {
port: portalStationPort, gateway,
indexPage: `merchant:index`,
};
let shopSettings = {
port: shopStationPort,
db: {
host: config.db_host,
port: config.db_port,
user: config.db_user,
password: config.db_password,
database: "shop_shop",
charset: "utf8",
}, gateway,
};
let imageSettings = {
port: imageStationPort,
db: {
host: config.db_host,
database: "shop_image",
port: config.db_port,
user: config.db_user,
password: config.db_password,
}
};
maishu_node_auth_1.start({
gatewaySettings: gatewayStationSettings,
permissionSettings: permissionStationSettings,
portalSettings: portalStationSettings,
}).then(() => {
shop_1.start(shopSettings);
maishu_image_service_1.start(imageSettings);
setTimeout(() => {
merchant_1.start({
gateway: gateway,
port: merchantStationPort,
permissionDB: permissionStationSettings.db,
gatewayDB: gatewayStationSettings.db,
logLevel: config.logLevel
});
}, 1000);
weixin_1.start({
port: weixinStationPort,
gateway: gateway,
db: {
host: config.db_host,
database: "shop_weixin",
port: config.db_port,
user: config.db_user,
password: config.db_password,
charset: "utf8"
}
});
member_1.start({
port: memberStationPort,
gateway: gateway,
db: {
host: config.db_host,
database: "shop_member",
port: config.db_port,
user: config.db_user,
password: config.db_password,
charset: "utf8"
}
});
account_1.start({
port: accountStationPort,
gateway
});
});
}
exports.start = start;
process.on("uncaughtException", function (err) {
console.error('An uncaught error occurred!');
console.error(err.stack);
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ansiboy/haoyi-shop.git
git@gitee.com:ansiboy/haoyi-shop.git
ansiboy
haoyi-shop
haoyi-shop
master

搜索帮助