Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/v3' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
dziraf committed Apr 4, 2023
2 parents 00fe999 + 286da71 commit a518292
Show file tree
Hide file tree
Showing 14 changed files with 3,796 additions and 4,129 deletions.
13 changes: 13 additions & 0 deletions example-app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.7'

services:
adminjs-import-export:
container_name: adminjs-import-export
image: mongo
ports:
- "27017:27017"
volumes:
- adminjs-import-export:/data/db

volumes:
adminjs-import-export:
10 changes: 0 additions & 10 deletions example-app/nodemon.json

This file was deleted.

29 changes: 19 additions & 10 deletions example-app/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
{
"name": "adminjs-import-export-example",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"license": "MIT",
"scripts": {
"dev": "nodemon",
"lint": "eslint src --ext ts"
"start": "node dist/example-app/src/server",
"build": "tsc -p './tsconfig.json'"
},
"dependencies": {
"@adminjs/design-system": "^2.0.4",
"@adminjs/express": "^4.0.1",
"adminjs": "^5.5.1",
"express": "^4.17.1",
"@adminjs/express": "^6.0.0-beta.3",
"@adminjs/mongoose": "^4.0.0-beta.4",
"express": "^4.18.2",
"express-formidable": "^1.2.0",
"nodemon": "^2.0.6",
"ts-node": "^9.0.0"
"express-session": "^1.17.3",
"mongoose": "^7.0.3",
"ts-node": "^10.9.1",
"tslib": "^2.5.0"
},
"devDependencies": {
"@types/express": "^4.17.8"
"@types/express": "^4.17.17",
"@types/node": "^18.15.11",
"typescript": "^5.0.2"
},
"resolutions": {
"@adminjs/design-system": "^4.0.0-beta-v4.8",
"@adminjs/express": "6.0.0-beta.3",
"@adminjs/mongoose": "4.0.0-beta.4",
"adminjs": "7.0.0-beta-v7.4"
}
}
25 changes: 15 additions & 10 deletions example-app/src/admin/admin.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import mongoose from 'mongoose';
import AdminJSExpress from '@adminjs/express';
import MongooseAdapter from '@adminjs/mongoose';
import AdminJS from 'adminjs';
import * as MongooseAdapter from '@adminjs/mongoose';
import AdminJS, { ComponentLoader } from 'adminjs';
import { Express } from 'express';
import { createUserResource } from './resources/user/user.resource';
import mongoose from 'mongoose';

import { createUserResource } from './resources/user/user.resource.js';

const setupAdmin = async (app: Express): Promise<void> => {
await mongoose.connect('mongodb://localhost:27017/adminjs-import-export', {
useNewUrlParser: true,
useUnifiedTopology: true,
await mongoose.connect('mongodb://localhost:27017/adminjs-import-export');

const componentLoader = new ComponentLoader();

AdminJS.registerAdapter({
Database: MongooseAdapter.Database,
Resource: MongooseAdapter.Resource,
});

AdminJS.registerAdapter(MongooseAdapter);
const adminJs = new AdminJS({
resources: [createUserResource()],
componentLoader,
resources: [createUserResource(componentLoader)],
});

const router = await AdminJSExpress.buildRouter(adminJs);
const router = AdminJSExpress.buildRouter(adminJs);
app.use(adminJs.options.rootPath, router);
};

Expand Down
18 changes: 13 additions & 5 deletions example-app/src/admin/resources/user/user.resource.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { ResourceWithOptions } from 'adminjs';
import { User } from './user.entity';
import importExportFeature from '../../../../../src/index';
import type { ComponentLoader, ResourceWithOptions } from 'adminjs';

export const createUserResource = (): ResourceWithOptions => ({
import importExportFeature from '../../../../../src/index.js';

import { User } from './user.entity.js';

export const createUserResource = (
componentLoader: ComponentLoader
): ResourceWithOptions => ({
resource: User,
options: {
navigation: {
icon: 'User',
name: 'Users',
},
},
features: [importExportFeature()],
features: [
importExportFeature({
componentLoader,
}),
],
});
3 changes: 2 additions & 1 deletion example-app/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import express from 'express';
import setupAdmin from './admin/admin';

import setupAdmin from './admin/admin.js';

const app = express();
const port = 3000;
Expand Down
15 changes: 9 additions & 6 deletions example-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"compilerOptions": {
"outDir": "./built",
"target": "ES2016",
"module": "CommonJS",
"jsx": "preserve",
"baseUrl": "./",
"outDir": "./dist",
"target": "esnext",
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
"emitDecoratorMetadata": true,
"skipLibCheck": true
},
"include": ["./src/**/*", "./spec/**/*"]
"include": ["./src/**/*.ts", "../src/**/*"]
}
Loading

0 comments on commit a518292

Please sign in to comment.