Coder Social home page Coder Social logo

cdnplz's Introduction

cdnplz

A tool for uploading file to cdn.

How to use?

const cdnplz = require('cdnplz');

try{
    new cdnplz({
        tpl_suffix: 'jade',   //the suffix of template file
        tpl_path: 'app/view', //the root path of template file
        static_path: '.',  //the path of the static file
        output_path: 'output/view/', //the output path of template file
        file_encoding: 'utf8',
        cdn_provider: 'yourCdnProvider',//the cdn provider provided by user
        cdn_options: {//the options of the cdn provider
            https: true
        }
    }).start();
}catch(e){
    console.log(e);
}

you should provide a cdn provider

const cdnProvider = require('yourCdnProvider');

module.exports = {
    upload: function(filePath, options){
        return cdnProvider.upload(filePath, options);
    }
}

Cdn provider should return a object which has a upload method, and this upload method takes filePath and options as parameters, returns a Promise. The data resolved by the Promise must be a Object like this:

{ 
  './static/img/logo.png': 'https://p1.ssl.qhimg.com/t010a4bf91e826708df.png' ,
  './static/js/main.js': 'https://s0.ssl.qhimg.com/static/c870687eb082c330.js'
} 

qiniu cdn Provider

https://github.com/webzhao/cdnplz-qiniu

cdnplz's People

Contributors

zhouweicsu avatar atwood-cai avatar

Stargazers

hheedat avatar wuyan avatar exp_work avatar NangeGao avatar 文蔺 avatar 逐日不二 avatar  avatar Wenbo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.