ipfs-gateway-emulator
Version:
A server emulating ipfs gateway behavior forked from local-web-server
62 lines (55 loc) • 1.52 kB
JavaScript
const LwsCli = require('lws/lib/cli-app')
const path = require('path')
class IPFSEmulatorCli extends LwsCli {
execute (options) {
if (options.defaultStack) {
const list = require('./default-stack')
this.log(list)
} else {
return super.execute(options)
}
}
getDefaultOptions () {
return Object.assign(super.getDefaultOptions(), {
stack: require('./default-stack').slice(),
moduleDir: [ '.', path.resolve(__dirname, '..') ]
})
}
partialDefinitions () {
return super.partialDefinitions().concat([
{
name: 'default-stack',
type: Boolean,
description: 'Print the default middleware stack. Any of these built-in middlewares are available to use in a custom stack.',
section: 'core'
}
])
}
usage () {
const sections = super.usage()
sections.shift()
sections.shift()
sections.pop()
sections.unshift(
{
header: 'ipfs-gateway-emulator',
content: 'An IPFS Gateway emulator that replic IPFS gateway behavior : index.html and redirection to folder/'
},
{
header: 'Synopsis',
content: [
'$ ipfs-emulator <options>'
]
}
)
sections.push({
content: 'Project home: {underline https://github.com/wighawag/local-web-server}'
})
return sections
}
showVersion () {
const pkg = require(path.resolve(__dirname, '..', 'package.json'))
this.log(pkg.version)
}
}
module.exports = IPFSEmulatorCli