55import 'reflect-metadata' ;
66import leafletFeatures , { getLeafletDist } from '@adminjs/leaflet' ;
77
8- import dotenv from 'dotenv' ;
9- dotenv . config ( { path : `${ process . cwd ( ) } /.env` } ) ;
10-
118import AdminJS , { ComponentLoader } from 'adminjs' ;
129import Plugin from '@adminjs/express' ;
1310import * as Adapter from '@adminjs/typeorm' ;
1411import express from 'express' ;
1512import cors from 'cors' ;
1613
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 ' ;
2017
2118const PORT = process . env . PORT ?? 8080 ;
2219
@@ -25,13 +22,14 @@ AdminJS.registerAdapter({
2522 Resource : Adapter . Resource ,
2623} ) ;
2724
25+ const componentLoader = new ComponentLoader ( ) ;
26+
2827const start = async ( ) => {
2928 await datasource . initialize ( ) ;
3029
31- const componentLoader = new ComponentLoader ( ) ;
32-
3330 const app = express ( ) ;
3431 app . use ( cors ( { origin : '*' } ) ) ;
32+ app . use ( express . static ( 'public' ) ) ;
3533 app . use ( express . static ( getLeafletDist ( ) ) ) ;
3634
3735 const markerPaths = {
@@ -42,6 +40,7 @@ const start = async () => {
4240 } ;
4341
4442 const admin = new AdminJS ( {
43+ componentLoader,
4544 assets : {
4645 styles : [ '/leaflet.css' ] ,
4746 } ,
@@ -74,7 +73,6 @@ const start = async () => {
7473 } ) ,
7574 ] ,
7675 } ] ,
77- componentLoader,
7876 rootPath : '/' ,
7977 } ) ;
8078
0 commit comments