@superhero/core.resource
v2.1.0
Published
Addon module to serve resources from a public folder to the @superhero/core module
Downloads
140
Readme
Core › Resource
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.
Install
npm install @superhero/core.resource
...or just set the dependency in your package.json
file:
{
"dependencies":
{
"@superhero/core.resource": "*"
}
}
Example Application
Example Application › File structure
App
├── view
│ ├── resource
│ │ └── js
│ │ └── foo.js
| └── config.js
├── index.js
└── package.json
package.js
{
"name": "Super Duper App",
"version": "0.0.1",
"description": "An example meant to describe the libraries fundamentals",
"license": "MIT",
"dependencies": {
"superhero": "*",
"@superhero/core.resource": "*"
}
}
config.js
module.exports =
{
core:
{
resource:
{
directory: 'view'
},
http:
{
server:
{
routes:
{
resource:
{
url : '/resource/.+',
endpoint : '@superhero/core.resource',
input : false
}
}
}
}
}
}
index.js
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))