npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

epay-ftl-middleware

v0.0.2

Published

middleware to render files include mock files and freemarker files

Downloads

5

Readme

epay-ftl-middleware

epay-ftl-middleware可作为中间件,能够渲染多个ftl项目,每个ftl项目可拥有自己独立的视图目录(include等指令以此路径为根)

功能

1、渲染多个ftl项目 2、ajax可以以视图路径为基准取到mock文件,格式支持js、json,html文件可直接返回

安装

$ npm install --save-dev epay-ftl-middleware

参数

  • router - {object}

    指定各项目对应server访问路径ftl视图路径之间的映射

    var router = {
        // 注意路径需要以“/”结尾,不要用跟base第一截相同的路径名
        // 若指定某个项目为跟路径“/”,则必须指定routePath属性为“/name”的形式
        '/project_a/': {
            name: 'a项目',
            // 视图基准路径视图视图基准路径路径,注意路径需要以“/”结尾,
            base: '/epay_project_a/src/main/webapp/WEB-INF/ftl/'
        },
        '/': {
            name: 'b项目',
            routePath: '/epayweb',
            base: '/epay_project_b/src/main/webapp/WEB-INF/ftl/'
        }
    };
    
  • filterFiles - {function} @params:req, files{array}

    读取的文件夹列表过滤规则,默认会在文件夹下所有文件路径中加入‘../’,在访问路径“/”时,会展示出所有项目。 如需自定义规则,可传入

  • filterMap - {object}

    可直接粗暴指定某真实路径对应读取的文件夹路径列表

    {
      '/epay_project_a/src/main/webapp/WEB-INF/ftl/': ['file.html', 'dir/', '../', {
        href: '../../',
        text: '上上级别'
      }]
    }
    

example

var fs = require('fs');
var path = require('path');
var express = require('express');
var app = express();
var port = 9000;
var ftlMiddleWare = require('epay-ftl-middleware');

var router = {
  '/project_a/': {
    name: 'a项目',
    base: '/epay_project_a/src/main/webapp/WEB-INF/ftl/'
  },
  '/project_b/': {
    name: 'b项目',
    base: '/epay_project_b/src/main/webapp/WEB-INF/ftl/'
  },
  '/': {
    name: '主项目',
    routePath: '/epayweb',
    base: '/epay_project_main/src/main/webapp/WEB-INF/ftl/'
  }
};

// 静态映射
app.use('/cdn_static', express.static('cdn_static'));
app.use(ftlMiddleWare({
    router: router
}));

app.listen(port);
setTimeout(function () {
  console.log('> server start at localhost:' + port)
});

License

The MIT License (MIT)