Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Armour committed Apr 16, 2021
2 parents 88b7440 + 37bde84 commit 3123189
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Base api
# Remeber to change this to your production server address
# Here I used my mock server for this project
VUE_APP_BASE_API = 'https://vue-typescript-admin-mock-server.armour.now.sh/mock-api/v1/'
VUE_APP_BASE_API = 'https://vue-typescript-admin-mock-server-armour.vercel.app/mock-api/v1/'
9 changes: 4 additions & 5 deletions mock/mock-server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import express from 'express'
import bodyParser from 'body-parser'
import compression from 'compression'
import morgan from 'morgan'
import cors from 'cors'
Expand All @@ -8,10 +7,10 @@ import path from 'path'
import yaml from 'yamljs'
import * as api from './api'
import { accessTokenAuth } from './security'
import { connector, summarise } from 'swagger-routes-express'

const app = express()
const port = 9528
const { connector, summarise } = require('swagger-routes-express')

// Compression
app.use(compression())
Expand All @@ -20,8 +19,8 @@ app.use(morgan('dev'))
// Enable CORS
app.use(cors())
// POST, PUT, DELETE body parser
app.use(bodyParser.json({ limit: '20mb' }))
app.use(bodyParser.urlencoded({
app.use(express.json({ limit: '20mb' }))
app.use(express.urlencoded({
limit: '20mb',
extended: false
}))
Expand All @@ -48,7 +47,7 @@ const apiSummary = summarise(apiDefinition)
console.log(apiSummary)

// Catch 404 error
app.use((req, res, next) => {
app.use((req, res) => {
const err = new Error('Not Found')
res.status(404).json({
message: err.message,
Expand Down
6 changes: 3 additions & 3 deletions mock/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const userList: IUserData[] = [
introduction: 'I am a super administrator',
email: 'admin@test.com',
phone: '1234567890',
roles: ['admin'],
roles: ['admin']
},
{
id: 1,
Expand All @@ -23,7 +23,7 @@ const userList: IUserData[] = [
introduction: 'I am an editor',
email: 'editor@test.com',
phone: '1234567890',
roles: ['editor'],
roles: ['editor']
}
]
const userCount = 100
Expand Down Expand Up @@ -91,7 +91,7 @@ export const getUserInfo = (req: Request, res: Response) => {
return res.json({
code: 20000,
data: {
user: req.header('X-Access-Token') == 'admin-token' ? userList[0] : userList[1]
user: req.header('X-Access-Token') === 'admin-token' ? userList[0] : userList[1]
}
})
}
Expand Down
Loading

0 comments on commit 3123189

Please sign in to comment.