Skip to content

Commit

Permalink
add config (#262)
Browse files Browse the repository at this point in the history
* add config

* update config
  • Loading branch information
lu-yg authored Jan 19, 2024
1 parent 421dda2 commit 435f817
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 16 additions & 0 deletions mockServer/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

module.exports = {
port: process.env.MOCK_PORT || 9090,
env: process.env.NODE_ENV || 'development' // Current mode
}
7 changes: 3 additions & 4 deletions mockServer/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import Koa2 from 'koa'
import KoaBody from 'koa-body'
import KoaStatic from 'koa-static2'
import path from 'path'
import MainRoutes from './routes/main-routes'
import { env, port } from '../config/config'
import ErrorRoutesCatch from './middleware/ErrorRoutesCatch'
import ErrorRoutes from './routes/error-routes'
import MainRoutes from './routes/main-routes'

const app = new Koa2()
const env = process.env.NODE_ENV || 'development' // Current mode
const PORT = 9090
app
.use((ctx, next) => {
ctx.set('Access-Control-Allow-Origin', '*')
Expand Down Expand Up @@ -57,6 +56,6 @@ if (env === 'development') {
})
}

app.listen(PORT)
app.listen(port)

export default app

0 comments on commit 435f817

Please sign in to comment.