5
5
import 'reflect-metadata' ;
6
6
import leafletFeatures , { getLeafletDist } from '@adminjs/leaflet' ;
7
7
8
- import dotenv from 'dotenv' ;
9
- dotenv . config ( { path : `${ process . cwd ( ) } /.env` } ) ;
10
-
11
8
import AdminJS , { ComponentLoader } from 'adminjs' ;
12
9
import Plugin from '@adminjs/express' ;
13
10
import * as Adapter from '@adminjs/typeorm' ;
14
11
import express from 'express' ;
15
12
import cors from 'cors' ;
16
13
17
- import datasource from './db/datasource' ;
18
- import { Marker } from './db/marker.entity' ;
19
- import { Map as MapEntity } from './db/map.entity' ;
14
+ import datasource from './db/datasource.js ' ;
15
+ import { Marker } from './db/marker.entity.js ' ;
16
+ import { Map as MapEntity } from './db/map.entity.js ' ;
20
17
21
18
const PORT = process . env . PORT ?? 8080 ;
22
19
@@ -25,13 +22,14 @@ AdminJS.registerAdapter({
25
22
Resource : Adapter . Resource ,
26
23
} ) ;
27
24
25
+ const componentLoader = new ComponentLoader ( ) ;
26
+
28
27
const start = async ( ) => {
29
28
await datasource . initialize ( ) ;
30
29
31
- const componentLoader = new ComponentLoader ( ) ;
32
-
33
30
const app = express ( ) ;
34
31
app . use ( cors ( { origin : '*' } ) ) ;
32
+ app . use ( express . static ( 'public' ) ) ;
35
33
app . use ( express . static ( getLeafletDist ( ) ) ) ;
36
34
37
35
const markerPaths = {
@@ -42,6 +40,7 @@ const start = async () => {
42
40
} ;
43
41
44
42
const admin = new AdminJS ( {
43
+ componentLoader,
45
44
assets : {
46
45
styles : [ '/leaflet.css' ] ,
47
46
} ,
@@ -74,7 +73,6 @@ const start = async () => {
74
73
} ) ,
75
74
] ,
76
75
} ] ,
77
- componentLoader,
78
76
rootPath : '/' ,
79
77
} ) ;
80
78
0 commit comments