Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
922765ab
Commit
922765ab
authored
Apr 09, 2015
by
杨翌文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改为正式环境的分支
parent
27630325
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
24 deletions
+31
-24
app.js
app.js
+4
-1
express.js
config/express.js
+27
-23
No files found.
app.js
View file @
922765ab
...
...
@@ -39,4 +39,7 @@ mongoModels.forEach(function(model) {
global
.
mongodb
=
mongodb
;
require
(
'./config/express'
)(
app
,
config
);
app
.
listen
(
config
.
port
);
\ No newline at end of file
app
.
listen
(
config
.
port
);
process
.
on
(
'uncaughtException'
,
function
(
err
){
console
.
log
(
err
);
});
\ No newline at end of file
config/express.js
View file @
922765ab
...
...
@@ -27,7 +27,7 @@ module.exports = function(app, config) {
store
:
new
redisStore
({
host
:
config
.
sessionStore
.
host
,
port
:
config
.
sessionStore
.
port
,
prefix
:
'
sandbox
-session-'
,
prefix
:
'
node
-session-'
,
pass
:
config
.
sessionStore
.
password
,
ttl
:
86400
}),
...
...
@@ -44,29 +44,29 @@ module.exports = function(app, config) {
}));
//添加中间件以支持跨域调用
app
.
use
(
function
(
req
,
res
,
next
)
{
res
.
header
(
"Access-Control-Allow-Origin"
,
"*"
);
res
.
header
(
"Access-Control-Allow-Headers"
,
"Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With"
);
res
.
header
(
"Access-Control-Allow-Methods"
,
"GET, PUT, POST"
);
res
.
header
(
'Access-Control-Max-Age'
,
7200
);
next
();
});
//
app.use(function(req, res, next) {
//
res.header("Access-Control-Allow-Origin", "*");
//
res.header("Access-Control-Allow-Headers", "Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
//
res.header("Access-Control-Allow-Methods", "GET, PUT, POST");
//
res.header('Access-Control-Max-Age', 7200);
//
next();
//
});
app
.
use
(
function
(
req
,
res
,
next
)
{
if
(
!
req
.
session
.
user
&&
req
.
query
.
key
&&
req
.
query
.
key
===
'aiwanpai'
)
{
req
.
session
.
user
=
{
ent_code
:
100041
};
}
if
(
!
req
.
session
.
openUser
&&
req
.
query
.
key
&&
req
.
query
.
key
===
'aiwanpai'
)
{
req
.
session
.
openUser
=
{
openId
:
'1111'
,
integral
:
'100'
,
exp
:
'100'
};
}
next
(
null
);
});
//
app.use(function(req, res, next) {
//
if (!req.session.user && req.query.key && req.query.key === 'aiwanpai') {
//
req.session.user = {
//
ent_code: 100041
//
};
//
}
//
if (!req.session.openUser && req.query.key && req.query.key === 'aiwanpai') {
//
req.session.openUser = {
//
openId: '1111',
//
integral: '100',
//
exp: '100'
//
};
//
}
//
next(null);
//
});
//设置创建用户中间件
...
...
@@ -83,6 +83,10 @@ app.use('/v1/forum/*',forumUser.identifyUser());
next
(
err
);
});
process
.
on
(
'uncaughtException'
,
function
(
err
){
console
.
log
(
err
);
});
// if (app.get('env') === 'development') {
// app.use(function(err, req, res, next) {
// res.json({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment