mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 04:07:14 +03:00
469b5b5790
* DefferedPromise refactor * Moved defferedPromise to utils folder * Base url moved to app file * Store modules states rewrittten according to vue doc recommendations * Deffered promise usage moved * removed unused packages in entries * Structure refactor, easier building, prod building configured, tsconfig reconfigure removed useless packages * Update front/index.html Co-Authored-By: avele <34437766+avele@users.noreply.github.com> * Update front/postcss.config.js Co-Authored-By: avele <34437766+avele@users.noreply.github.com> * Comment rewritten
35 lines
806 B
TypeScript
35 lines
806 B
TypeScript
import Koa from 'koa'
|
|
import bodyparser from 'koa-bodyparser'
|
|
import proxy from 'koa-proxy'
|
|
import config from './config.js'
|
|
|
|
const { port, apiUrl } = config
|
|
const isProduction = process.env.NODE_ENV === 'production'
|
|
|
|
async function start () {
|
|
const app = new Koa()
|
|
|
|
// TODO replace proxy lib or write own middleware for log and flexibility
|
|
app.use(proxy({
|
|
requestOptions: {
|
|
strictSSL: false
|
|
},
|
|
host: apiUrl,
|
|
match: /^\/api\//,
|
|
map: (path: string) => path.replace('/api', '')
|
|
}))
|
|
app.use(bodyparser())
|
|
|
|
const setupServer = isProduction
|
|
? (await import('./build/setupProdServer')).default
|
|
: (await import('./build/setupDevServer')).default
|
|
|
|
await setupServer(app)
|
|
|
|
app.listen(port, () => {
|
|
console.log(`[Info] Server is on at ${port}.`)
|
|
})
|
|
}
|
|
|
|
start()
|