Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit d897952

Browse files
committed
feat(api): split api based on api functionality
1 parent cab8f0b commit d897952

5 files changed

Lines changed: 33 additions & 9 deletions

File tree

.env.development

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
VUE_APP_XHR_REST=https://easy-mock.com/mock/5bf3bcec941747724a67a53a/at
2-
VUE_APP_KEY=development_key
3-
VUE_APP_SECRET=development_secret
2+
VUE_APP_GITHUB_API=https://api.github.com
3+
VUE_APP_CLIENT_ID=development_client_id

.env.production

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
VUE_APP_XHR_REST=https://easy-mock.com/mock/5bf3bcec941747724a67a53a/at
2-
VUE_APP_KEY=development_key
3-
VUE_APP_SECRET=development_secret
2+
VUE_APP_GITHUB_API=https://api.github.com
3+
VUE_APP_CLIENT_ID=production_client_id

src/api/github/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import routes from '../routes'
2+
import createRequest from 'UTILS/request'
3+
4+
const http = createRequest({
5+
baseURL: process.env.VUE_APP_GITHUB_API
6+
})
7+
8+
export function fetchCommitList() {
9+
return http.get(routes.COMMIT_LIST)
10+
}
11+
12+
export function fetchLastRelease() {
13+
return http.get(routes.LAST_RELEASE)
14+
}

src/api/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import routes from './routes'
2-
import createBaseRequest from 'UTILS/request'
2+
import createRequest from 'UTILS/request'
33

4-
const restBaseRequest = createBaseRequest(process.env.VUE_APP_XHR_REST)
4+
export * from './github'
5+
6+
const http = createRequest({
7+
baseURL: process.env.VUE_APP_XHR_REST,
8+
headers: {
9+
Client_Id: process.env.VUE_APP_CLIENT_ID
10+
},
11+
auth: true
12+
})
513

614
export function userLogin({ username, password }) {
7-
return restBaseRequest.post(routes.LOGIN, {
15+
return http.post(routes.LOGIN, {
816
username,
917
password
1018
})
1119
}
1220

1321
export function fetchUserAccess(token) {
14-
return restBaseRequest.post(routes.ACCESS, {
22+
return http.post(routes.ACCESS, {
1523
token
1624
})
1725
}

src/api/routes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export default {
22
LOGIN: '/user/login',
3-
ACCESS: '/user/access'
3+
ACCESS: '/user/access',
4+
COMMIT_LIST: '/repos/lbwa/adminize-template/commits',
5+
LAST_RELEASE: '/repos/lbwa/adminize-template/releases/latest'
46
}

0 commit comments

Comments
 (0)