I just installed adminJs in my nestJs application. After going through all the difficulties and following the work around, the nestJS app runs without issue but when going to the adminJS default route i get nothing but a 404 error.
so route http://localhost:3000/admin does not seem to even exist, despite http://localhost:3000 working well and other routes as well like http://localhost:3000/api etc...
Here is my app.module config:
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AppController } from './app.controller.js';
import { MongooseModule } from '@nestjs/mongoose';
import { AppService } from './app.service.js';
import { ConfigModule } from '@nestjs/config';
import { SiweModule } from './siwe/siwe.module.js';
import { OrchestratorModule } from './orchestrator/orchestrator.module.js';
import { MerkleTreeModule } from './merkle-tree/merkle-tree.module.js';
import { DatabaseModule } from './database/database.module.js';
import { MongoSanitizeMiddleware } from './middleware/mongo.sanitize.middleware.js';
const DEFAULT_ADMIN = {
email: 'admin@example.com',
password: 'password',
}
const authenticate = async (email: string, password: string) => {
if (email === DEFAULT_ADMIN.email && password === DEFAULT_ADMIN.password) {
return Promise.resolve(DEFAULT_ADMIN)
}
return null
}
@Module({
imports: [import('@adminjs/nestjs').then(({ AdminModule }) => AdminModule.createAdminAsync({
useFactory: () => ({
adminJsOptions: {
rootPath:'/admin',
resources: [],
},
auth: {
authenticate,
cookieName: 'adminjs',
cookiePassword: 'secret'
},
sessionOptions: {
resave: true,
saveUninitialized: true,
secret: 'secret'
}
}),
})),ConfigModule.forRoot({isGlobal: true}),MongooseModule.forRoot(process.env.MONGO_URI as string ), SiweModule, OrchestratorModule,
MerkleTreeModule, DatabaseModule,],
controllers: [AppController],
providers: [AppService],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(MongoSanitizeMiddleware).forRoutes('*');
}
}
here is my ts.config:
{
"compilerOptions": {
"moduleResolution": "node16",
"module": "Node16",
"target": "esnext",
"esModuleInterop":true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": false,
"strictBindCallApply": false,
"noFallthroughCasesInSwitch": false
},
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
}
i am lost. As a side note, if i can't fix this issue quickly, an equivalent alternative might be suggested.
The AdminJs team seems to be aware of this issue.
It seems it's likely caused by Nest v11. You can start your project with Nest v10 or subscribe to the issue and wait for a patch.