我有这个咖啡脚本代码:
dirs = ["/assets", "/public", "/locales", "/data/topo"]
app.configure ->
app.use assets(build : true)
jsPaths assets, console.log
@use(express.favicon(process.cwd() + "/assets/images/favicon.ico", {maxAge:maxAges}))
.use(express.compress())
.use(express.static(process.cwd() + "/assets", {maxAge:maxAges}))
.use(express.static(process.cwd() + "/public", {maxAge:maxAges}))
.use(express.static(process.cwd() + "/locales", {maxAge:maxAges}))
.use(express.static(process.cwd() + "/data/topo", {maxAge:maxAges}))
.use(express.logger('dev'))
.use(express.errorHandler(
dumpException: true
showStack: true
))
# Add template engine
我想为所有dirs = ["/assets", "/public", "/locales", "/data/topo"]
设置maxAge,这样做的正确方法是什么?
任何建议都值得赞赏。
答案 0 :(得分:0)
为每个数组项调用一个方法?
setMaxAge folder for folder in ["/assets", "/public", "/locales", "/data/topo"]
setMaxAge(folder) ->
app.use express.static( process.cwd() + folder, maxAge:maxAges )
或单行:
app.use express.static(process.cwd() + folder, maxAge:maxAges) for folder in ["/assets", "/public", "/locales", "/data/topo"]