• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript falcor-express.dataSourceRoute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中falcor-express.dataSourceRoute函数的典型用法代码示例。如果您正苦于以下问题:TypeScript dataSourceRoute函数的具体用法?TypeScript dataSourceRoute怎么用?TypeScript dataSourceRoute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dataSourceRoute函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

  constructor() {

    // setup express router
    this.expressRouter = ExpressRouter();

    this.registerMicroservices();

    this.falcorRouter = FalcorRouter.createClass(this.routeSet);

    this.expressRouter.use("/model", falcorExpress.dataSourceRoute((req, res) => {
      return new this.falcorRouter();
    }));

  }
开发者ID:cdhgee,项目名称:whencaniretire,代码行数:14,代码来源:ApiManager.ts


示例2: constructor

  constructor(expressRouter: express.Router){
    this.expressRouter = expressRouter;
    this.routes = [];

    // add microservices
    let fundsService: FundsService = new FundsService(this);
    let dashboardService: DashboardService = new DashboardService(this);
    let activityService: ActivityService = new ActivityService(this);
    // add base partial route

    let RouterClass = FalcorRouter.createClass(this.routes);

    this.expressRouter.use("/model.json", FalcorExpress.dataSourceRoute((req: express.Request, res: express.Response) => {
      return new RouterClass();
    }));

  }
开发者ID:cdhgee,项目名称:investments,代码行数:17,代码来源:DataModelRouter.ts


示例3:

    ],
    start_url: `/read?webapp=1`,
    display: "standalone"
  }));
});
app.use('/offline.html', express.static('../offline.html'));
app.use('/service-worker.js', express.static('service-worker.js'));
app.use('/service-worker.js.map', express.static('service-worker.js.map'));
app.use('/service-worker.ts', express.static('../service-worker.ts'));
app.use('/ui/common.js', express.static('ui/common.js'));
app.use('/ui/common.js.map', express.static('ui/common.js.map'));
app.use('/ui/common.ts', express.static('../ui/common.ts'));

// falcor data model
app.use('/model.json', FalcorExpress.dataSourceRoute(function(req, res) {
  return falcorModel.asDataSource();
}));

/**
 * Call this function as a default parameter in order to enforce required
 * URL parameters. It will throw an Error if the param is not provided.
 *
 * ```
 * ({slug = required('slug')}) => new Page(slug)
 * ```
 *
 * For optional parameters, just provide a default string value:
 *
 * ```
 * ({offset = '0'}) => new OtherPage(offset);
 * ```
开发者ID:CompassHB,项目名称:web,代码行数:31,代码来源:server.ts


示例4: express

const app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.static(__dirname)); // ExpressとElectronが両立する書き方。
  
app.get('/', (req, res) => {
  res.redirect('/views');
});

app.get('/views', (req, res) => {
  res.render('index', { title: 'ExpressApp', mode: EXPRESS_ENV });
});

app.use('/model.json', falcorExpress.dataSourceRoute((req, res) => {
  //return new MinimongoFalcorRouter(); // 引数のreq, resで何が出来るのかわからないので無視。
  return null;
}));

const port = 3000; // Number(EXPRESS_PORT) || 3000;
const host = 'localhost'; // EXPRESS_HOST; // || getIPAddress();
app.listen(port, host);
console.log('Express server listening at http://%s:%s as "%s" mode.', host, port, EXPRESS_ENV);
export {host, port}


// function getIPAddress() {
//   const interfaces = require('os').networkInterfaces();
//   for (let devName in interfaces) {
//     const iface = interfaces[devName];

//     for (let i = 90; i < iface.length; i++) {
开发者ID:ovrmrw,项目名称:webpack-typescript-angular2-1,代码行数:31,代码来源:express.ts


示例5: require

  res.json({
    data: 'fake data'
  });
});


var falcorExpress = require('falcor-express');
var Router = require('falcor-router');

app.use('/model.json', falcorExpress.dataSourceRoute((req, res) => {
  // create a Virtual JSON resource with single key ("greeting")
  return new Router([
    {
      route: 'greeting',
      get: () => {
        return {
          path: ['greeting'],
          value: 'Hello World'
        };
      }
    }
  ]);
}));
// Routes with html5pushstate
app.use('/', ngApp);
app.use('/about', ngApp);
app.use('/home', ngApp);

// Server
app.listen(PORT, () => {
  console.log('Process ' + process.pid + ' Listen on ' + ORIGIN);
});
开发者ID:gdi2290,项目名称:angular2-falcor-starter,代码行数:32,代码来源:index.ts


示例6: function

module.exports = function(ROOT) {

  var router = Router();

  router.use('/todos', falcorExpress.dataSourceRoute(function(req, res) {
    return new falcorRouter([
      {
        route: 'all',
        get: function() {
          console.log('GET');
          return {path: ['all'], value: TODOS};
        }
      },
      {
        route: 'all',
        set: function(jsonGraphArg) {
          TODOS = jsonGraphArg.all;
          return {path: ['all'], value: TODOS};
        }
      },
      {
        route: 'todo',
        get: function(pathSet) {
          var id = Number(pathSet.todo);

          try {
            var todo = TODOS[id];
            return {path: ['todo'], value: todo};
          } catch (e) {
            throw new Error('failed to load todo');
          }
        }
      },
      {
        route: 'todo.push',
        call: function(callPath, args) {
          var todo = args[0];
          TODOS.push(todo);

          return {path: ['all'], value: todo};
        }
      },
      {
        route: 'todo.id.remove',
        call: function(callPath, args) {
          var id = args[0];
          var i = TODOS.length;

          while (i--) {
            if (TODOS[i].id === id) { break; }
          }

          if (i > -1) {
            var todo = TODOS.splice(i, 1)[0];
            return {path: ['todo'], value: todo};
          }

          throw new Error ('failed to delete todo');
        }
      }
    ]);
  }));

  return router;
};
开发者ID:BizagiStudio,项目名称:universal,代码行数:65,代码来源:graph_api.ts



注:本文中的falcor-express.dataSourceRoute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript falcor-json-graph.pathInvalidation函数代码示例发布时间:2022-05-25
下一篇:
TypeScript falafel.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap