zoukankan      html  css  js  c++  java
  • loopback 代码解析

    loopback-boot

    boot(app, __dirname);//server.js

    • var instructions = compile(options);
      execute(app, instructions, callback); //(index.js)

    • setHost(app, instructions);
      setPort(app, instructions);
      setApiRoot(app, instructions);
      applyAppConfig(app, instructions);

      setupDataSources(app, instructions);
      setupModels(app, instructions);

    • 初始化配置:环境、数据源、model (lib/executor.js)
    • 初始化路由? -- where angular-routes
    • async.series([
      function(done) {
      runBootScripts(app, instructions, done);
      },

    //读取所有server/boot/目录下面的, (配置对应的路由与处理可以写在这里)

    • 配置restapi 路由

    loopback route 处理:

    • first go through middleware: proxy rate-limit oAuth https-redirect 做权限等检查
    • 最终到达api end point (我们的api controller处理)  , check out  loopback-gateway 

    自带 mobile  sdk:

    • //简化了重复解析json结构的流程,直接上一个object
      ModelRepository productRepository = adapter.createRepository("product"); Model pen = productRepository.createModel( ImmutableMap.of("name", "Awesome Pen") );

    项目结构:

    - common
    |---- models // both server and client use
    - client
    |---- models-config.json //view in Angular or hybrid mobile app
    - server
    |---- models-config.json

    example https://github.com/strongloop/loopback-example-full-stack

      

  • 相关阅读:
    闭包
    this
    函数声明,表达式,构造函数
    算法学习_栈
    LeetCode刷题_140
    2020/3/20 刷题
    2020/3/19 刷题
    2020/3/13_C++实验课
    刷题(主要是DFS) 2020年3月12日
    DFS的一些题2020/3/11
  • 原文地址:https://www.cnblogs.com/no7dw/p/4111872.html
Copyright © 2011-2022 走看看