Skip to content

Commit

Permalink
fix: vercel serverless functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zce committed Dec 27, 2021
1 parent c0a03cd commit a817f35
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions api/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Root Express Application
* Standalone Express Application
* for vercel serverless functions
*/

import express from 'express'
import app from './app'
import mock from '../mock'

export default express().use('/api', app)
export default express().use('/api', mock)
4 changes: 2 additions & 2 deletions api/_play.http → mock.http
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ## /auth
@api_base = http://localhost:3000/api
@access_token = 17b2fbbeabd11f7217b2fbbeabd17a85
@refresh_token = 17b200b3194196f917b200b319419a88
@access_token = 17dfbf0dd1c116a217dfbf0dd1c16907
@refresh_token = 17dfb982a9b1a16c17dfb982a9b1cca3

# ==============================================================================

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion api/app.ts → mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ app.use((req, res, next) => {

// endpoints
app.use('/auth', require('./auth').default)
app.use('/menus', require('./menus').default)
app.use('/menus1', require('./menus').default)
app.use('/users', require('./users').default)
app.use('/labs', require('./labs').default)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"license": "MIT",
"author": "zce <w@zce.me> (https://zce.me)",
"scripts": {
"lint": "eslint src api --ext .ts,.vue --fix",
"lint": "eslint src api mock --ext .ts,.vue --fix",
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview",
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
},
"include": [
"api/**/*.ts",
"api/**/*.d.ts",
"mock/**/*.ts",
"mock/**/*.d.ts",
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.vue"
"src/**/*.vue",
"vite.config.ts"
]
}
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import { defineConfig, Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
import mockApi from './api'
import mockApp from './mock'

const mock = (): Plugin => ({
name: 'mock',
configureServer: async server => {
// Add mock server, `/api` is the base url
server.middlewares.use(mockApi)
// mount mock server, `/api` is the base url
server.middlewares.use('/api', mockApp)
}
})

Expand Down

1 comment on commit a817f35

@vercel
Copy link

@vercel vercel bot commented on a817f35 Dec 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.