Merge pull request #1312 from syuilo/domain

Domain
This commit is contained in:
syuilo 2018-03-27 12:46:11 +09:00 committed by GitHub
commit 4814ac9d45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 6 deletions

View File

@ -140,11 +140,11 @@ export default function load() {
mixin.hostname = url.hostname; mixin.hostname = url.hostname;
mixin.scheme = url.protocol.replace(/:$/, ''); mixin.scheme = url.protocol.replace(/:$/, '');
mixin.ws_scheme = mixin.scheme.replace('http', 'ws'); mixin.ws_scheme = mixin.scheme.replace('http', 'ws');
mixin.ws_url = `${mixin.ws_scheme}://api.${mixin.host}`; mixin.ws_url = `${mixin.ws_scheme}://${mixin.host}`;
mixin.secondary_host = config.secondary_url.substr(config.secondary_url.indexOf('://') + 3); mixin.secondary_host = config.secondary_url.substr(config.secondary_url.indexOf('://') + 3);
mixin.secondary_hostname = secondaryUrl.hostname; mixin.secondary_hostname = secondaryUrl.hostname;
mixin.secondary_scheme = config.secondary_url.substr(0, config.secondary_url.indexOf('://')); mixin.secondary_scheme = config.secondary_url.substr(0, config.secondary_url.indexOf('://'));
mixin.api_url = `${mixin.scheme}://api.${mixin.host}`; mixin.api_url = `${mixin.scheme}://${mixin.host}/api`;
mixin.auth_url = `${mixin.scheme}://auth.${mixin.host}`; mixin.auth_url = `${mixin.scheme}://auth.${mixin.host}`;
mixin.ch_url = `${mixin.scheme}://ch.${mixin.host}`; mixin.ch_url = `${mixin.scheme}://ch.${mixin.host}`;
mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`; mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`;

View File

@ -53,7 +53,7 @@ app.use((req, res, next) => {
/** /**
* Register modules * Register modules
*/ */
app.use(vhost(`api.${config.hostname}`, require('./api/server'))); app.use('/api', require('./api/server'));
app.use(vhost(config.secondary_hostname, require('./himasaku/server'))); app.use(vhost(config.secondary_hostname, require('./himasaku/server')));
app.use(vhost(`file.${config.secondary_hostname}`, require('./file/server'))); app.use(vhost(`file.${config.secondary_hostname}`, require('./file/server')));
app.use(require('./web/server')); app.use(require('./web/server'));

View File

@ -1,7 +1,7 @@
import { EventEmitter } from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import * as uuid from 'uuid'; import * as uuid from 'uuid';
import * as ReconnectingWebsocket from 'reconnecting-websocket'; import * as ReconnectingWebsocket from 'reconnecting-websocket';
import { apiUrl } from '../../../config'; import { wsUrl } from '../../../config';
import MiOS from '../../mios'; import MiOS from '../../mios';
/** /**
@ -42,14 +42,13 @@ export default class Connection extends EventEmitter {
this.state = 'initializing'; this.state = 'initializing';
this.buffer = []; this.buffer = [];
const host = apiUrl.replace('http', 'ws');
const query = params const query = params
? Object.keys(params) ? Object.keys(params)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k])) .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
.join('&') .join('&')
: null; : null;
this.socket = new ReconnectingWebsocket(`${host}/${endpoint}${query ? '?' + query : ''}`); this.socket = new ReconnectingWebsocket(`${wsUrl}/${endpoint}${query ? '?' + query : ''}`);
this.socket.addEventListener('open', this.onOpen); this.socket.addEventListener('open', this.onOpen);
this.socket.addEventListener('close', this.onClose); this.socket.addEventListener('close', this.onClose);
this.socket.addEventListener('message', this.onMessage); this.socket.addEventListener('message', this.onMessage);

View File

@ -2,6 +2,7 @@ declare const _HOST_: string;
declare const _HOSTNAME_: string; declare const _HOSTNAME_: string;
declare const _URL_: string; declare const _URL_: string;
declare const _API_URL_: string; declare const _API_URL_: string;
declare const _WS_URL_: string;
declare const _DOCS_URL_: string; declare const _DOCS_URL_: string;
declare const _STATS_URL_: string; declare const _STATS_URL_: string;
declare const _STATUS_URL_: string; declare const _STATUS_URL_: string;
@ -20,6 +21,7 @@ export const host = _HOST_;
export const hostname = _HOSTNAME_; export const hostname = _HOSTNAME_;
export const url = _URL_; export const url = _URL_;
export const apiUrl = _API_URL_; export const apiUrl = _API_URL_;
export const wsUrl = _WS_URL_;
export const docsUrl = _DOCS_URL_; export const docsUrl = _DOCS_URL_;
export const statsUrl = _STATS_URL_; export const statsUrl = _STATS_URL_;
export const statusUrl = _STATUS_URL_; export const statusUrl = _STATUS_URL_;

View File

@ -80,6 +80,7 @@ module.exports = entries.map(x => {
_STATS_URL_: config.stats_url, _STATS_URL_: config.stats_url,
_DOCS_URL_: config.docs_url, _DOCS_URL_: config.docs_url,
_API_URL_: config.api_url, _API_URL_: config.api_url,
_WS_URL_: config.ws_url,
_DEV_URL_: config.dev_url, _DEV_URL_: config.dev_url,
_CH_URL_: config.ch_url, _CH_URL_: config.ch_url,
_LANG_: lang, _LANG_: lang,