https://github.com/datodia/adminjs-nestjs
Nestjs adminjs example app
https://github.com/datodia/adminjs-nestjs
adminjs adminjs-nestjs example nestjs tutorial
Last synced: 6 months ago
JSON representation
Nestjs adminjs example app
- Host: GitHub
- URL: https://github.com/datodia/adminjs-nestjs
- Owner: Datodia
- Created: 2025-03-26T19:09:56.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-26T21:00:15.000Z (10 months ago)
- Last Synced: 2025-05-08T23:11:38.993Z (9 months ago)
- Topics: adminjs, adminjs-nestjs, example, nestjs, tutorial
- Language: TypeScript
- Homepage:
- Size: 175 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Adminjs Nestjs example
## How to setup project
1. clone projcet
2. use node 20 version like 20.13.1(LTS) its not working node 20+ versions
3. npm i
4. create .env and add here DB_URL=
5. npm run start:dev // for starting project
## How to add new resources?
1. nest g res posts
2. inside a mongoose folder add post-model.ts file
3. copy user-model.ts file and configure it as you want, add new props.
4. dont forget to change also interface and schema name, like inteface Post and PostSchema
5. import it inside of mongoose.module.ts file, especially
``` ts
MongooseModule.forFeature( [
{ name: 'Admin', schema: AdminSchema },
{ name: 'User', schema: UserSchema },
//here add new resource
{ name: 'Post', schema: PostSchema }
]),
```
7. go to post.module.ts and import new mongooseModule.forfeature
``` ts
imports: [
MongooseModule.forFeature([{name: 'Post', schema: PostSchem}])
],
```
7. inject postModel inside a post.service.ts and write logics that you want.
8. most important part inside an app.module.ts you should add your resource.
``` ts
inject: [
getModelToken('Admin'),
getModelToken('User'),
getModelToken('Post'), // add new resourse
],
```
``` ts
useFactory: (
adminModel: Model,
userModel: Model,
postModel: Mode // dont forget that
) => ({
adminJsOptions: {
rootPath: '/admin',
resources: [
{ resource: adminModel },
{ resource: userModel },
],
},
...
```
9. thats all npm run start:dev /admin use username: admin@example.com and pass: password