Ftl-server of front and back end separation tools

Source: Internet
Author: User

Article Source: Https://www.npmjs.com/package/ftl-server

Ftl-server is a front-end development tool that supports parsing freemarker templates, simulating backend interfaces, and reverse proxies.

Characteristics

    • Parsing freemarker Templates
    • Static Resource Services
    • Mock request
    • Proxy request
    • Livereload
    • Weinre

Installation

1. NPM Install Ftl-server-g

2. In the project directory, create a new configuration file, such as Ftl.config.js, under the root directory, the configuration file format is as follows:

Module.exports ={public:' E:\\somedir\\public ',//Static file directory port:' 80 ',//port number, default to hot:true,///Boolean, whether to turn on livereload, change CSS to automatically update the page style after opening, modify ftl/js/picture, etc. automatically refresh the page watch: [Require.resolve ('./page.ftl '), ' E:\\ftlserver\page.mock '],//additional configuration files that need to be monitored, values are remotedebug for the array: {// remoteDebug configuration browser for weinre:' Firefox '}, FTL: {//config Freemarker for resolution base:' E:\\SOMEDIR\\FTL ',//configure Freemarker Template directory datafiles: [' E:\\SOMEDIR\\DATA.FTL '],//Configure the data file required by the FTL template, which is the file global: {//FTL shared data file},' FTLFILE.FTL ':function(req, res) {//key FTLFILE.FTL represents the FTL file to render, and value represents the data that renders the FTLreturn{saleactivitymap: {"000008": {activitystatus:' Actived '}}}} , mock: [{//Interface impersonation, impersonation request path:'/request ',//Request name method:' Get ',//Request method Status:' 200 ',//Request status Header: {//Request header}, Response:function(req, res) {//Requested return contentreturn{A:1, B:2      }    }  }, ' E:\\mock\\mock.js '],//file format see the following source code proxy: [{path:'/proxy1 ',//indicates a request to reverse proxy path target:' http://localhost:3000 '//indicates the destination address of the agent    }  ]}

The e:\\mock\\mock.js format is as follows:

       //module.exports = [{'/mock ', ' post ',   function (req, res) {      return  {          true      }  }}]

Execute fs-c./ftl.config.js-p 1008 or ftl-server-c./ftl.config.js-p 1008

3. Visit the http://localhost:1008/to browse the FTL page in the directory directly.

Ftl-server of front and back end separation tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.