forked from tsnolan23/tailor-react-spa
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
347 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "mosaic-tailor-react-example", | ||
"name": "frontend-microservices", | ||
"version": "1.0.0", | ||
"description": "mosaic-tailor-react-example", | ||
"description": "Frontend microservices", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "micro -l tcp://0.0.0.0:80", | ||
|
@@ -12,14 +12,14 @@ | |
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tsnolan23/mosaic-tailor-react-example.git" | ||
"url": "git+https://github.com/morriq/Frontend-microservices.git" | ||
}, | ||
"author": "", | ||
"author": "morriq<[email protected]>", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/tsnolan23/mosaic-tailor-react-example/issues" | ||
"url": "https://github.com/morriq/Frontend-microservices/issues" | ||
}, | ||
"homepage": "https://github.com/tsnolan23/mosaic-tailor-react-example#readme", | ||
"homepage": "https://github.com/morriq/Frontend-microservices#readme", | ||
"devDependencies": { | ||
"babel-eslint": "^9.0.0", | ||
"eslint": "^5.6.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { machineIdSync } = require('node-machine-id') | ||
const { address } = require('ip') | ||
|
||
|
||
const setId = (id) => ({ id }) | ||
const setName = (name) => ({ name }) | ||
const setAddress = (address) => ({ address }) | ||
const setPort = port => ({ port }) | ||
|
||
const getUrlFromPort = (port) => (path) => { | ||
// @todo | ||
return `//localhost:${port}/${path}` | ||
} | ||
|
||
const { env } = process | ||
const { | ||
npm_package_name, | ||
npm_package_config_port | ||
} = env | ||
|
||
module.exports = ({ | ||
...setId(machineIdSync()), | ||
...setName(npm_package_name), | ||
...setAddress(address()), | ||
...setPort(Number(npm_package_config_port)), | ||
|
||
getUrl: getUrlFromPort(npm_package_config_port) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 24 additions & 1 deletion
25
...ment-applications-react/package-lock.json → packages/fragment-react/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { machineIdSync } = require('node-machine-id') | ||
const { address } = require('ip') | ||
|
||
|
||
const setId = (id) => ({ id }) | ||
const setName = (name) => ({ name }) | ||
const setAddress = (address) => ({ address }) | ||
const setPort = port => ({ port }) | ||
|
||
const getUrlFromPort = (port) => (path) => { | ||
// @todo | ||
return `//localhost:${port}/${path}` | ||
} | ||
|
||
const { env } = process | ||
const { | ||
npm_package_name, | ||
npm_package_config_port | ||
} = env | ||
|
||
module.exports = ({ | ||
...setId(machineIdSync()), | ||
...setName(npm_package_name), | ||
...setAddress(address()), | ||
...setPort(Number(npm_package_config_port)), | ||
|
||
getUrl: getUrlFromPort(npm_package_config_port) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const consul = require('consul') | ||
const url = require('url') | ||
const { createReadStream } = require('fs') | ||
|
||
const { id, address, name, port } = require('./environment.js') | ||
const renderStream = require('./render-stream.js') | ||
|
||
|
||
const bundleStream = createReadStream('./dist/bundle.js') | ||
|
||
|
||
const { agent } = consul({ | ||
host: 'consul', | ||
promisify: true | ||
}) | ||
|
||
agent.service.register({ | ||
id, | ||
name, | ||
address, | ||
port | ||
}) | ||
.catch(() => { | ||
'logowanie do spana' | ||
}) | ||
|
||
module.exports = (req, res) => { | ||
const pathname = url.parse(req.url).pathname | ||
const jsHeader = { 'Content-Type': 'application/javascript' } | ||
switch(pathname) { | ||
case '/dist/bundle.js': | ||
res.writeHead(200, jsHeader) | ||
bundleStream.pipe(res) | ||
break | ||
default: | ||
res.writeHead(200, { | ||
'Content-Type': 'text/html', | ||
'Link': '<http://localhost:80/dist/bundle.js> rel="fragment-script"' | ||
}) | ||
|
||
renderStream().pipe(res) | ||
} | ||
} |
Oops, something went wrong.