1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 2× 2× 6× 2× 2× 2× 2× 2× 1× 2× 2× 8× | import { absolute } from 'ethical-utility-path' import minimatch from 'minimatch' const route = async (ctx, next, config) => { const { file: { path } } = ctx const { pattern } = config const resolvedPattern = absolute(pattern) const resolvedPath = absolute(path) if (minimatch(resolvedPath, resolvedPattern)) { await next() } } const routeInit = (pattern) => { const config = { pattern } return async (ctx, next) => await route(ctx, next, config) } export default routeInit |