Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deps && fix pathname #5

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,47 @@
}
},
"peerDependencies": {
"@adminjs/design-system": "^2.0.4",
"adminjs": "^5.5.1"
"@adminjs/design-system": "^2.2.4",
"adminjs": "^5.10.3"
},
"devDependencies": {
"@adminjs/design-system": "^2.0.4",
"@adminjs/express": "^4.0.1",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@semantic-release/git": "^9.0.0",
"@types/express": "^4.17.9",
"@types/jest": "^26.0.15",
"@types/json2csv": "^5.0.1",
"@types/xml": "^1.0.5",
"@types/xml2js": "^0.4.5",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"adminjs": "^5.5.1",
"date-fns": "^2.16.1",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"express": "^4.17.1",
"@adminjs/design-system": "^2.2.4",
"@adminjs/express": "^4.1.3",
"@commitlint/cli": "^17.0.1",
"@commitlint/config-conventional": "^17.0.0",
"@semantic-release/git": "^10.0.1",
"@types/express": "^4.17.13",
"@types/jest": "^27.5.1",
"@types/json2csv": "^5.0.3",
"@types/xml": "^1.0.8",
"@types/xml2js": "^0.4.11",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"adminjs": "^5.10.3",
"date-fns": "^2.28.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"express": "^4.18.1",
"express-formidable": "^1.2.0",
"express-session": "^1.17.2",
"husky": "^4.3.0",
"jest": "^26.6.1",
"prettier": "^2.1.2",
"semantic-release": "^17.2.2",
"ts-jest": "^26.4.3",
"ts-node": "^9.0.0",
"typescript": "^4.0.5"
"express-session": "^1.17.3",
"husky": "^8.0.1",
"jest": "^28.1.0",
"prettier": "^2.6.2",
"semantic-release": "^19.0.2",
"ts-jest": "^28.0.3",
"ts-node": "^10.8.0",
"typescript": "^4.7.2"
},
"dependencies": {
"@adminjs/mongoose": "^2.0.0",
"@types/mongoose": "^5.7.37",
"@adminjs/mongoose": "^2.0.3",
"@types/mongoose": "^5.11.97",
"csvtojson": "^2.0.10",
"file-saver": "^2.0.2",
"json2csv": "^5.0.3",
"mongoose": "^5.10.11",
"file-saver": "^2.0.5",
"json2csv": "^5.0.7",
"mongoose": "^6.3.4",
"xml": "^1.0.1",
"xml2js": "^0.4.23"
}
Expand Down
9 changes: 5 additions & 4 deletions src/import.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export const importHandler: ActionHandler<ActionResponse> = async (
context
) => {
const file = getFileFromRequest(request);
const importer = getImporterByFileName(file.name);

const fileContent = await readFile(file.name);
await importer(fileContent.toString(), context.resource);
if (file.name !== null) {
const importer = getImporterByFileName(file.name);
const fileContent = await readFile(file.path);
await importer(fileContent.toString(), context.resource);
}

return {};
};
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
BaseRecord,
BaseResource,
Filter,
UploadedFile,
ValidationError,
} from 'adminjs';
import { Importer } from './parsers';
Expand Down Expand Up @@ -52,7 +53,7 @@ export const postActionHandler = (
return handler(request, response, context);
};

export const getFileFromRequest = (request: ActionRequest): File => {
export const getFileFromRequest = (request: ActionRequest): UploadedFile => {
const file = request.payload?.file;

if (!file?.path) {
Expand Down
Loading