1
1
import Koa from 'koa' ;
2
2
import helmet from 'koa-helmet' ;
3
+ // import koaLogger from 'koa-logger';
3
4
import send from 'koa-send' ;
4
5
import serve from 'koa-static' ;
5
- import path from 'path' ;
6
+ import * as path from 'path' ;
6
7
import * as appInsights from 'applicationinsights' ;
7
8
8
- import { config } from './config' ;
9
- import { logger } from './logging' ;
10
- import { routes } from './routes/index' ;
9
+ import { config } from './config.js' ;
10
+ import { logger } from './logging.js' ;
11
+ import { routes } from './routes/index.js' ;
12
+
13
+ // const stripAnsi = await import('strip-ansi');
11
14
12
15
if ( config . appInsightsConnectionString ) {
13
16
appInsights
@@ -21,8 +24,9 @@ if (config.appInsightsConnectionString) {
21
24
22
25
const app = new Koa ( ) ;
23
26
27
+ // app.use(koaLogger((text) => stripAnsi(text)));
24
28
app . use (
25
- helmet . contentSecurityPolicy ( {
29
+ helmet . default . contentSecurityPolicy ( {
26
30
useDefaults : true ,
27
31
directives : {
28
32
scriptSrc : [ "'self'" , "'unsafe-inline'" , 'storage.googleapis.com' , 'www.google-analytics.com' ] ,
@@ -33,7 +37,7 @@ app.use(
33
37
app . use ( logger ) ;
34
38
app . use ( routes ) ;
35
39
36
- const publicPath = path . join ( __dirname , '..' , 'client' , 'dist' ) ;
40
+ const publicPath = path . join ( path . dirname ( import . meta . url ) , '..' , 'client' , 'dist' ) ;
37
41
38
42
app . use ( serve ( publicPath ) ) ;
39
43
app . use ( async ( ctx ) => {
0 commit comments