首页 > 代码库 > loopback 代码解析

loopback 代码解析

loopback-boot

boot(app, __dirname);

  • 初始化配置:环境、数据源、model
  • 初始化路由? -- where angular-routes
  • 读取所有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

  

loopback 代码解析