Server Rendering
Development
Install Node packages
$ npm install
Start development server
$ npm start
Configuration
You can view all your configuration settings in src/config/Config.js
.
The environment variables you will need to set during configuration are:
COMPONENT_DIR_PATH
// This is the absolute path you want the server to look in when loading your components.
// Example:
// If your JavaScript files are in todo-web/app/assets/javascripts,
// then you want to set your COMPONENT_DIR_PATH environment variable to:
// todo-web/app/assets/javascripts
Production
Compile to from ES6 to ES5
$ npm run build
Run production server
$ npm run production
How to Use
Get a health check
$ curl http://localhost:8080/health #=> OK
Render component via POST
$ curl -d '{ "component": "Test", "props": { "name": "Kylo" } }' \
-H "Content-Type: application/json" \
http://localhost:8080/render
Sample response
{
"metadata": {
"component": "Test",
"props": {
"name": "Kylo"
}
},
"html": "<div aria-hidden="true" class="modal modal__container"><div class="modal__table"><div class="modal__cell"><div class="modal__content"></div></div></div></div>"
}
You can render the component via GET in your browser (only in development):
http://localhost:8080/test/render?component=Test&name=Kylo