在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:koajs/resourcer开源软件地址:https://github.com/koajs/resourcer开源编程语言:JavaScript 90.6%开源软件介绍:resourcerA simple resource directory mounter for koa. var koa = require('koa');
var resource = require('koa-resourcer');
var app = koa();
resource(app, join(__dirname, 'resources') [, callback])
app.listen(); The idea behind Directory structureSay we have the following directory structure:
We have three independent apps here. var koa = require('koa')
var mount = require('koa-mount')
var app = koa()
var v1users = require('./v1/users/app.js')
app.use(mount('v1/users/', v1users))
var v2users = require('./v2/users/fun.js')
app.use(mount('v2/users/', v2users))
var v1products = require('./v1/products/')
app.use(mount('v1/products/', v1products))
// and so on, and so on, for each of your sub apps....
app.listen() With var koa = require('koa')
var join = require('path').join
var resource = require('koa-resourcer')
var app = koa()
resource(app, join(__dirname, 'resources'))
app.listen() config.jsonEach application directory must contain a // resources/v1/users/config.json
{ "source": "app.js" } By relying on the directory structure to determine route paths, // resources/v1/users/config.json
{ "source": "app.js", "path": "user" } By adding the CallbacksIf you pass a callback function as the third argument to var koa = require('koa')
var join = require('path').join
var resource = require('koa-resourcer')
var app = koa()
resource(app, join(__dirname, 'resources'), function(o){
console.log('mounted %s', o.path, o.resource)
})
app.listen() Installation
Developmentrunning tests
verbose logging
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论