我刚刚注意到了一些我没想到的东西.我一直试图"搞"它一段时间,但没有完全管理.它让我疯狂......
采用标准的Expressjs文件.我补充说:
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, path = require('path');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.post( '/call/loginAnon', function(req,res, next){
console.log("IN THE CALL! %j %j %j", req.path, req.body, req.headers );
next();
});
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.index);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
}); …
Run Code Online (Sandbox Code Playgroud) 我有一个显示记录的 dom-repeat 元素,我想在 dom-repeat完成后运行一个操作。这样我就可以运行:
this.$.content.scrollTop = this.$.content.scrollHeight;
Run Code Online (Sandbox Code Playgroud)
(这是一个聊天系统,不向下滚动到最后一个是愚蠢的)。
这是一个相当普通的 dom-repeat 模板......我尝试将自己作为它的过滤器,或者观察数据,但在所有情况下,我在渲染发生之前被调用。
这是 dom-repeat —— 我该怎么做?
<div class="content" id="content">
<div class="container-fluid">
<template is="dom-if" if="[[!_dataThere(data)]]">
<my-empty-list icon="question-answer" message="You haven't talk to this user yet. (You can do it now!)"></my-empty-list>
</template>
<hot-network manage-errors>
<iron-ajax id="aj" auto url="{{_makeUrl(userId,userData.generic.id)}}" handle-as="json" last-response="{{data}}"></iron-ajax>
<template is="dom-if" if="[[_dataThere(data)]]">
<template is="dom-repeat" items="[[data]]">
<div class$="message {{_theirsOrMine(item)}}">
<div class="message-inner">
<div class="avatar"></div>
<div class="bubble">{{ item.message}}</div>
</div>
<div class="meta">{{_formattedDate(item.added)}}</div>
</div>
</template>
</template>
</hot-network>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
app.post('/routes/passwordReset/:userId', async (req, res, next) => {
var userId = req.params.userId
let record = (await vars.connection.queryP('SELECT * FROM contacts WHERE id = ?', userId))[0]
if (!record) {
res.status(404).send('')
return
}
// Calculate token and expiry, update database
var token = require('crypto').randomBytes(48).toString('base64').replace(/[^a-zA-Z0-9]/g, '').substr(0, 28)
var now = new Date()
var inOneHour = new Date(now.getTime() + (1 * 1000 * 60 * 60))
await vars.connection.queryP('UPDATE contacts SET recoverToken = ?, recoverTokenExpiry = ? WHERE id = ?', [ token, inOneHour, userId …
Run Code Online (Sandbox Code Playgroud) 我有一个传递给函数的对象,并希望保存带有这些值的数据库条目,并选择具有一些默认值.
实际上......
我在Mongoose中有这样的模式:
var Log = new Schema({
workspaceId : { type: String, index: true },
workspaceName : { type: String, index: true },
loginSession : { type: String, index: true },
loginToken : { type: String, index: true },
logLevel : { type: Number, enum:[0,1] },
errorName : { type: String, index: true },
message : { type: String, index: true },
reqInfo : { type: String },
data : { type: String },
loggedOn : { type: Date, …
Run Code Online (Sandbox Code Playgroud)