1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-22 20:31:31 +03:00
guide/front/server.ts
avele 469b5b5790
Front/structure refactor and building reconfigure (#277)
* 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
2019-04-18 01:52:43 +04:00

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()