0.0.8 • Published 6 years ago

y-server-plugin-template v0.0.8

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

y-server-plugin-template

y-server-plugin-template is a y-server template render plugin.

Install

npm install y-server-plugin-template

Usage

const path = require('path');

const yServer = require('y-server');
const mockPlugin = require('y-server-plugin-mock');
const ejsPlugin = require('y-server-plugin-ejs');
const templatePlugin = require('y-server-plugin-template');

yServer({
  plugins: [
    mockPlugin({
      mockEnable: true,
      mockDir: path.join(__dirname, './json'), // 模拟数据根目录
      mockAdapter: require('./json/adapter.js'),
    }),
    ejsPlugin({
      viewDir: path.join(__dirname, './view'), // 模板根目录
      renderAdapter: (result) => {
        result.$render = true;
        return result;
      },
    }),
    templatePlugin({
      routes: {
        '/rank': { view: 'rank.html', cgi: '/majax/rank' },
        'localhost:10024/category': { view: 'rank.html', cgi: '/majax/category' },
      },
      apiServer: 'http://m.readnovel.com', // 后端 server
      apiOptions: {
        query: {},
        headers: {},
      },
    }),
  ],
});

Notes

  • defaultHost is the default host of route path.
  • routes is the routes config.
  • apiServer is the api server.
  • apiOptions is the api options (see request).

License

MIT License

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago