Licence: MIT
This is an addon module to the superhero/core module. This addon is a simple dispatcher that can be used to serve public resources.
npm install @superhero/core.resource
...or just set the dependency in your package.json
file:
{
"dependencies":
{
"@superhero/core.resource": "*"
}
}
App
├── view
│ ├── resource
│ │ └── js
│ │ └── foo.js
| └── config.js
├── index.js
└── package.json
{
"name": "Super Duper App",
"version": "0.0.1",
"description": "An example meant to describe the libraries fundamentals",
"license": "MIT",
"dependencies": {
"superhero": "*",
"@superhero/core.resource": "*"
}
}
module.exports =
{
core:
{
resource:
{
directory: 'view'
},
http:
{
server:
{
routes:
{
resource:
{
url : '/resource/.+',
endpoint : '@superhero/core.resource',
input : false
}
}
}
}
}
}
const
CoreFactory = require('superhero/core/factory'),
coreFactory = new CoreFactory,
core = coreFactory.create()
core.add('view')
core.add('@superhero/core.resource')
core.load()
core.locate('bootstrap').bootstrap().then(() =>
core.locate('http/server').listen(process.env.HTTP_PORT))