Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
op-web-service
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
op-web-service
Commits
96866393
Commit
96866393
authored
Jun 09, 2021
by
lvweichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: fix koa use order
parent
8ae37e3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
14 deletions
+20
-14
app.js
app.js
+7
-3
role.js
server/controllers/role.js
+4
-9
request.js
src/utils/request.js
+9
-2
No files found.
app.js
View file @
96866393
const
Koa
=
require
(
'koa'
);
const
Koa
=
require
(
'koa'
);
const
views
=
require
(
'koa-views'
);
//
const views = require('koa-views');
const
serve
=
require
(
'koa-static'
);
const
serve
=
require
(
'koa-static'
);
const
koaBody
=
require
(
'koa-body'
);
const
koaBody
=
require
(
'koa-body'
);
const
bodyParser
=
require
(
'koa-bodyparser'
);
const
bodyParser
=
require
(
'koa-bodyparser'
);
...
@@ -11,11 +11,15 @@ const env = process.env.NODE_ENV;
...
@@ -11,11 +11,15 @@ const env = process.env.NODE_ENV;
const
app
=
new
Koa
();
const
app
=
new
Koa
();
app
.
use
(
koaBody
({
multipart
:
true
}));
app
.
use
(
bodyParser
());
app
.
use
(
router
.
routes
(),
router
.
allowedMethods
());
app
.
use
(
router
.
routes
(),
router
.
allowedMethods
());
app
.
use
(
serve
(
path
.
join
(
__dirname
,
'./public'
)));
app
.
use
(
serve
(
path
.
join
(
__dirname
,
'./public'
)));
app
.
use
(
koaBody
({
multipart
:
true
}));
app
.
use
(
bodyParser
());
app
.
listen
(
config
.
port
,
()
=>
{
app
.
listen
(
config
.
port
,
()
=>
{
console
.
info
(
console
.
info
(
...
...
server/controllers/role.js
View file @
96866393
const
LOGIN_URI
=
require
(
'../config.js'
).
LOGIN_URI
const
LOGIN_URI
=
require
(
'../config.js'
).
LOGIN_URI
const
API_INTERNAL_URI
=
require
(
'../config.js'
).
API_INTERNAL_URI
const
API_INTERNAL_URI
=
require
(
'../config.js'
).
API_INTERNAL_URI
const
req
=
require
(
'../utils/request'
).
httpReq
const
req
=
require
(
'../utils/request'
).
httpReq
const
controller_utils
=
require
(
'./utils'
)
exports
.
getAll_role_list
=
async
(
ctx
,
next
)
=>
{
exports
.
getAll_role_list
=
async
(
ctx
,
next
)
=>
{
var
url
=
`
${
API_INTERNAL_URI
}
/merchant/authority/get_role_list`
;
ctx
.
body
=
await
controller_utils
.
getUserPermission
(
ctx
);
var
opts
=
{
url
:
url
,
method
:
'POST'
,
json
:
true
,
timeout
:
8000
,
body
:
ctx
.
request
.
body
}
ctx
.
body
=
await
req
(
ctx
,
opts
)
}
}
exports
.
getRole_list
=
async
(
ctx
,
next
)
=>
{
exports
.
getRole_list
=
async
(
ctx
,
next
)
=>
{
var
url
=
`
${
API_INTERNAL_URI
}
/merchant/authority/role_list`
;
var
url
=
`
${
API_INTERNAL_URI
}
/merchant/authority/role_list`
;
...
...
src/utils/request.js
View file @
96866393
...
@@ -36,7 +36,14 @@ const getDefaultParams = () => {
...
@@ -36,7 +36,14 @@ const getDefaultParams = () => {
}
}
};
};
const
getDefaultHeaders
=
()
=>
{};
const
getDefaultHeaders
=
(
config
)
=>
{
const
{
method
}
=
config
;
if
(
method
.
toLowerCase
()
===
'post'
)
{
return
{
"Content-Type"
:
"application/json"
}
}
};
/**
/**
* axios instance
* axios instance
...
@@ -57,7 +64,7 @@ instance.interceptors.request.use(
...
@@ -57,7 +64,7 @@ instance.interceptors.request.use(
/**
/**
* merge headers
* merge headers
*/
*/
config
.
headers
=
{
...
getDefaultHeaders
(),
...
config
.
headers
}
config
.
headers
=
{
...
getDefaultHeaders
(
config
),
...
config
.
headers
}
/**
/**
* merge params
* merge params
...
...
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