diff --git a/README.md b/README.md index 097093f..e8c1761 100755 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Windows, Unix systems and macOS are supported. For Windows, you'll need to call Wait a bit while it reads the tutorial from the disk and builds static assets. - Then access the site at `http://127.0.0.1:3000`. + Then access the site at `http://127.0.0.1:3000`. **[Change Server Port](#change-server-port)** 7. Edit the tutorial @@ -92,6 +92,14 @@ cd /js/server Please note, the server must support that language. There must be corresponding locale files for that language in the code of the server, otherwise it exists with an error. As of now, `ru`, `en`, `zh`, `tr` and `ja` are fully supported. + +# Change Server Port + +The server uses port `3000` by default. + +In case, if you want to change the port, you can change it by editing `PORT` in `/js/server/modules/config/index.js` + + # Translating images Most pictures are in SVG format. Strings inside it are usually just text, they can be replaced. @@ -210,6 +218,7 @@ If it still doesn't work – [file an issue](https://github.com/javascript-tutor Please pull the very latest git code and install latest NPM modules before publishing an issue. + -- Yours, Ilya Kantor diff --git a/modules/config/index.js b/modules/config/index.js index 445d3c2..aa9dad7 100755 --- a/modules/config/index.js +++ b/modules/config/index.js @@ -2,6 +2,7 @@ let path = require('path'); let fs = require('fs-extra'); let yaml = require('js-yaml'); let env = process.env; +const PORT = 3000; // NODE_ENV = development || test || production env.NODE_ENV = env.NODE_ENV || 'development'; @@ -21,46 +22,46 @@ if (env.DEV_TRACE) { let config = module.exports = { urlBase: { // node may be behind nginx, use this in documents - main: new URL(env.URL_BASE_MAIN || env.URL_BASE || 'http://localhost:3000'), - static: new URL(env.URL_BASE_STATIC || env.URL_BASE || 'http://localhost:3000'), + main: new URL(env.URL_BASE_MAIN || env.URL_BASE || `http://localhost:${PORT}`), + static: new URL(env.URL_BASE_STATIC || env.URL_BASE || `http://localhost:${PORT}`), }, urlBaseProduction: { // when even in dev mode we must reference prod, use this (maybe remove it?) - main: new URL(env.URL_BASE_PRODUCTION_MAIN || env.URL_BASE || 'http://localhost:3000'), - static: new URL(env.URL_BASE_PRODUCTION_STATIC || env.URL_BASE || 'http://localhost:3000') + main: new URL(env.URL_BASE_PRODUCTION_MAIN || env.URL_BASE || `http://localhost:${PORT}`), + static: new URL(env.URL_BASE_PRODUCTION_STATIC || env.URL_BASE || `http://localhost:${PORT}`) }, server: { - port: env.PORT || 3000, + port: env.PORT || PORT, host: env.HOST || 'localhost' }, - appKeys: [secret.sessionKey], + appKeys: [secret.sessionKey], adminKey: secret.adminKey, - lang: lang, + lang: lang, plnkrAuthId: secret.plnkrAuthId, assetVersioning: env.ASSET_VERSIONING === 'file' ? 'file' : - env.ASSET_VERSIONING === 'query' ? 'query' : null, + env.ASSET_VERSIONING === 'query' ? 'query' : null, - pug: { + pug: { basedir: path.join(process.cwd(), 'templates'), - cache: env.NODE_ENV !== 'development' + cache: env.NODE_ENV !== 'development' }, supportEmail: 'iliakan@javascript.info', - projectRoot: process.cwd(), + projectRoot: process.cwd(), // public files, served by nginx - publicRoot: path.join(process.cwd(), 'public', lang), + publicRoot: path.join(process.cwd(), 'public', lang), // private files, for expiring links, not directly accessible - tutorialRoot: env.TUTORIAL_ROOT || path.join(process.cwd(), '..', lang + '.javascript.info'), - tmpRoot: path.join(process.cwd(), 'tmp', lang), + tutorialRoot: env.TUTORIAL_ROOT || path.join(process.cwd(), '..', lang + '.javascript.info'), + tmpRoot: path.join(process.cwd(), 'tmp', lang), // js/css build versions - cacheRoot: path.join(process.cwd(), 'cache', lang), - assetsRoot: path.join(process.cwd(), 'assets'), + cacheRoot: path.join(process.cwd(), 'cache', lang), + assetsRoot: path.join(process.cwd(), 'assets'), handlers: require('./handlers') }; @@ -69,13 +70,13 @@ let repo = `javascript-tutorial/${config.lang}.javascript.info`; config.tutorialRepo = { github: repo, - url: new URL('https://github.com/' + repo), - tree: new URL('https://github.com/' + repo + '/tree/master'), - blob: new URL('https://github.com/' + repo + '/blob/master') + url: new URL('https://github.com/' + repo), + tree: new URL('https://github.com/' + repo + '/tree/master'), + blob: new URL('https://github.com/' + repo + '/blob/master') }; -require.extensions['.yml'] = function(module, filename) { +require.extensions['.yml'] = function (module, filename) { module.exports = yaml.safeLoad(fs.readFileSync(filename, 'utf-8')); };