【发布时间】:2016-08-08 15:39:45
【问题描述】:
我对 Express 和 Keystone 非常陌生。一般来说,我想了解如何在 Keystone 中使用 Express 应用程序,即如何分解 Express 应用程序并将其导入 Keystone,或将 Express 模块与 Keystone 集成。更具体地说,作为开始,我想简单地使用 Stormpath 来验证我的用户。 Stormpath 提供了一个 Express 示例。我认为这是一个典型的简单 Express 应用程序,如何将它或类似的类似 Express 应用程序合并到 Keystone 中,即如何将其分解为 Keystone 中的相应部分和文件?
谢谢!
'use strict';
var express = require('express');
var stormpath = require('express-stormpath');
var routes = require('./lib/routes');
/**
* Create the Express application.
*/
var app = express();
/**
* Application settings.
*/
app.set('trust proxy',true);
app.set('view engine', 'jade');
app.set('views', './lib/views');
app.locals.siteName = 'Express-Stormpath Example Project';
/**
* Stormpath initialization.
*/
console.log('Initializing Stormpath');
app.use(stormpath.init(app, {
expand: {
customData: true
} }));
/**
* Route initialization.
*/
app.use('/', routes);
app.on('stormpath.ready',function () {
console.log('Stormpath Ready');
});
/**
* Start the web server.
*/
var port = process.env.PORT || 3000;
app.listen(port, function () {
console.log('Server listening on http://localhost:' + port);
});
【问题讨论】:
标签: express keystonejs