• Stars
    star
    533
  • Rank 82,675 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A generic administration interface for TypeORM entities

NestJS Admin

A generic administration interface for TypeORM entities

NPM Version

Proudly sponsored by Theodo


Description

Ready-to-use user interface for administrative activities. Allows to list, edit, create, delete entities.

This is heavily, heavily inspired by Django admin, from the concept to the API.

This is still very much a work in progress. Your help is more than welcome! The API is still very unstable. Until a 1.x.x release, expect breaking changes in minor versions

Full docs: https://nestjs-admin.com/

All your entities in one place. Create, update and delete entities with ease.

Installation

Let's get you started with a minimal setup.

  1. Add nestjs-admin to your dependencies:
yarn add nestjs-admin # With yarn
npm install nestjs-admin # With NPM
  1. Then add the provided DefaultAdminModule to your app modules:
// src/app.module.ts
import { Module } from '@nestjs/common'
import { DefaultAdminModule } from 'nestjs-admin'

@Module({
  imports: [TypeOrmModule.forRoot(), /* ... */, DefaultAdminModule],
  /* ... */,
})
export class AppModule {
  /* ... */
}
  1. Add the provided AdminUser to your orm config:

The DefaultAdminModule exposes an AdminUser entity, which has credentials that allow you to login to the admin interface.

There's no easy option to use your own user entity for now. If you have this requirement, open an issue so that we can help you.

// If you use an ormconfig.js
const AdminUser = require('nestjs-admin').AdminUserEntity
module.exports = {
  /* ... */,
  entities: [/* ... */, AdminUser],
  // Alternatively:
  // entities: [/* ... */, 'node_modules/nestjs-admin/**/*.entity.js'],
}
# If you use environment variables
TYPEORM_ENTITIES=your_existing_paths,node_modules/nestjs-admin/**/*.entity.js
  1. Create a first AdminUser to log in with
# Create the AdminUser schema in database
npx ts-node node_modules/.bin/typeorm migration:generate -n "create-admin-user"
npx ts-node node_modules/.bin/typeorm migration:run

# Now you can create an AdminUser through the CLI
npx nestjs-admin createAdminUser

You can create AdminUsers from the nestjs-admin createAdminUser CLI, or directly from the administration interface!

You can now login to access the admin interface at /admin/login!

  1. Register entities in the admin site
// user.module.ts
import { TypeOrmModule } from '@nestjs/typeorm'
import { Module } from '@nestjs/common'
import { DefaultAdminModule, DefaultAdminSite } from 'nestjs-admin'
import { User } from './user.entity'

@Module({
  imports: [TypeOrmModule.forFeature([User]), DefaultAdminModule],
  exports: [TypeOrmModule],
})
export class UserModule {
  constructor(private readonly adminSite: DefaultAdminSite) {
    // Register the User entity under the "User" section
    adminSite.register('User', User)
  }
}

Check the rest of the docs for more details.

Compatibility

Library Version
@nestjs/common ^6.0.0
@nestjs/core ^6.0.0
@nestjs/platform-express ^6.0.0
@nestjs/typeorm ^6.0.0
typeorm ^0.2.12

Contributing

Any contribution is welcome. If you want to implement a feature, you need to know that we are following django-admin's API as closely as possible. Why?

  • It's been well-thought-out by smart people
  • Python translates well to Typescript
  • It allows us to not have to think about what the API should look like and just use Django admin as a list of desirable features

Start the example app

This repo contains an example of how to use nestjs-admin. Here's how to use it:

# In a first terminal, run the database
cp .env.example .env
docker-compose up

# In a second terminal, compile the library
yarn install
yarn link
yarn start:dev

# In a third terminal, run the example app
cd exampleApp/
yarn install
yarn link nestjs-admin
yarn migration:run
yarn start:debug

You can now create an AdminUser (yarn nestjs-admin createAdminUser) to be able to login to localhost:8000/admin.

The code for the actual library is in libs/nestjs-admin.

Tooling

If you use VSCode, a .vscode/ is committed that contains a good configuration to contribute. In particular, it contains a config for a ready-to-use debugger.

ADRs

You'll find ADRs in docs/adr

More Repositories

1

rntv-blog

TypeScript
51
star
2

theodo-good-tests

Sharing of testing philosophy and best practices with commonly used examples
Python
40
star
3

expo-preview-branches

Preview Branches for Expo using EAS CLI
29
star
4

drfrf

Django REST framework - redux-form connector
Python
23
star
5

django-enhanced-emails

๐Ÿ”‹ Batteries-included emails for Django
Python
21
star
6

RN-common-docs

Common docs for React Native projects having used the env generator
21
star
7

generator-rn-toolbox

The React Native Generator to bootstrap your apps ๐Ÿ› ๏ธ
20
star
8

formik-blueprint

JavaScript
19
star
9

OmniLog

Observability tool for your LLM prompts!
TypeScript
12
star
10

offline-goodies

Javascript goodies to help creating an offline app
JavaScript
10
star
11

blog-koa-jwt

Bruno and Victor's repo for their koa articles
JavaScript
9
star
12

theodo-good-tests-runnable-examples

Some runnable examples from theodo-good-tests
JavaScript
4
star
13

react-native-workshop

Fast deployment of a React-Native app
Objective-C
3
star
14

sustainability-calculator

A calculator that measures the carbon impact of the page you are on
TypeScript
3
star
15

release-notes

Automatically generates release notes from your PRs
JavaScript
2
star
16

BookifyApp

A concept React Native book information application using Google Books API with nice UI design. Author is Joshua Gornall
Java
1
star
17

actions

TypeScript
1
star
18

legendary-sniffle

CSS
1
star
19

enzyme-react-seo

Generic Enzyme test suite SEO analyzer for React web applications
JavaScript
1
star
20

khancycle

A React Native app for iOS and Android to let you know if you Khan or Khan't find a public hire bike
Objective-C
1
star