Giter VIP home page Giter VIP logo

learn-javascript's Issues

view-koa下面为什么要加入对生产环境的判断

view-koa
// static file support: if (! isProduction) { let staticFiles = require('./static-files'); app.use(staticFiles('/static/', __dirname + '/static')); }

为什么要这么做的呢?
为什么不是production才导入staticFiles呢?

node.js v4.4.1不支持...rest?

本机node环境为4.4.1版本,按照源代码直接执行mocha命令后,报错如下:

/Users/Jacksun/Sites/Koa2/hello.js:6
module.exports = function(...rest){
                          ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/Jacksun/Sites/Koa2/test/hello-test.js:8:13)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at /Users/Jacksun/Sites/Koa2/node_modules/mocha/lib/mocha.js:220:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/Jacksun/Sites/Koa2/node_modules/mocha/lib/mocha.js:217:14)
    at Mocha.run (/Users/Jacksun/Sites/Koa2/node_modules/mocha/lib/mocha.js:485:10)
    at Object.<anonymous> (/Users/Jacksun/Sites/Koa2/node_modules/mocha/bin/_mocha:403:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

谢谢廖老师的精彩课程,但是关于nodejs课程下的koa的model章节有一些问题,想要问一下

首先是,当我跟着课程写db.js,不管是参照课程里的,还是参照github上的,都会报错:
sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security,
我看有篇CSDN写了有关该课程是因为执行函数后面忘了写;分号.但是我几番检查,该处代码完全没有像([{+;之类的问题,而且问题出现在new sequellize里.除非是在new里声明operatorsAliases: false,否则一直warning.原因到底是因为什么?

其二是,在github上的代码,添加了课程里面没有的,当创建一个orm后会输出的console.log,这这里面有一些循环处理,但是 if (v instanceof dbType) 这句话一直报TypeError: Function has non-object prototype 'undefined' in instanceof check,应该是还要在嵌套一个if判断v的instanceof指向吧?

关于templating.js

你好廖老师
关于你的view-koa项目
不太明白为什么在templating.js中这样写

function templating(path, opts) { var env = createEnv(path, opts); return async (ctx, next) => { ctx.render = function (view, model) { ctx.response.body = env.render(view, Object.assign({}, ctx.state || {}, model || {})); ctx.response.type = 'text/html'; }; await next(); }; }

请问这段代码是怎么使controller里面的ctx添加render()函数的?

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.