本文整理汇总了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;未经允许,请勿转载。 |
请发表评论