Skip to content

Commit 125b471

Browse files
committed
local adapter progress
1 parent 1036f99 commit 125b471

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

adminforth/modules/codeInjector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class CodeInjector implements ICodeInjector {
129129
});
130130
process.env.HEAVY_DEBUG && console.timeEnd(`npm ${command} done in`);
131131

132-
process.env.HEAVY_DEBUG && console.log(`🪲 npm ${command} output:`, out);
132+
// process.env.HEAVY_DEBUG && console.log(`🪲 npm ${command} output:`, out);
133133
if (err) {
134134
process.env.HEAVY_DEBUG && console.error(`🪲npm ${command} errors/warnings:`, err);
135135
}

dev-demo/resources/apartments.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import CompletionAdapterOpenAIChatGPT from "../../adapters/adminforth-completion
1616
import ImageGenerationAdapterOpenAI from "../../adapters/adminforth-image-generation-adapter-openai/index.js";
1717
import AdminForthAdapterS3Storage from "../../adapters/adminforth-storage-adapter-amazon-s3/index.js";
1818
import AdminForthAdapterLocal from "../../adapters/adminforth-storage-adapter-local/index.js";
19+
import AdminForthStorageAdapterLocalFilesystem from "../../adapters/adminforth-storage-adapter-local/index.js";
20+
import AdminForth from "../../adminforth";
1921

2022

2123
const demoChecker = async ({ record, adminUser, resource }) => {
@@ -25,6 +27,19 @@ const demoChecker = async ({ record, adminUser, resource }) => {
2527
return { ok: true };
2628
};
2729

30+
declare global {
31+
namespace NodeJS {
32+
interface ProcessEnv {
33+
AWS_ACCESS_KEY_ID: string;
34+
AWS_SECRET_ACCESS_KEY: string;
35+
AWS_REGION: string;
36+
AWS_BUCKET: string;
37+
ADMINFORTH_SECRET: string;
38+
OPENAI_API_KEY: string;
39+
}
40+
}
41+
}
42+
2843
export default {
2944
dataSource: "maindb",
3045
table: "apartments",
@@ -326,13 +341,20 @@ export default {
326341
new UploadPlugin({
327342
pathColumnName: "apartment_source",
328343

329-
storageAdapter: new AdminForthAdapterS3Storage({
330-
region: "eu-central-1",
331-
bucket: "tmpbucket-adminforth",
332-
accessKeyId: process.env.AWS_ACCESS_KEY_ID as string,
333-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string,
334-
s3ACL: 'public-read', // ACL which will be set to uploaded file
344+
// storageAdapter: new AdminForthAdapterS3Storage({
345+
// region: "eu-central-1",
346+
// bucket: "tmpbucket-adminforth",
347+
// accessKeyId: process.env.AWS_ACCESS_KEY_ID,
348+
// secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
349+
// s3ACL: 'public-read', // ACL which will be set to uploaded file
350+
// }),
351+
352+
storageAdapter: new AdminForthStorageAdapterLocalFilesystem({
353+
fileSystemFolder: "./db/uploads",
354+
mode: "public", // public if all files should be accessible from the web, private only if could be accesed by temporary presigned links
355+
signingSecret: process.env.ADMINFORTH_SECRET, // secret used to generate presigned URLs
335356
}),
357+
336358
allowedFileExtensions: [
337359
"jpg",
338360
"jpeg",
@@ -343,7 +365,7 @@ export default {
343365
"webp",
344366
],
345367
maxFileSize: 1024 * 1024 * 20, // 5MB
346-
s3Path: ({ originalFilename, originalExtension, contentType, record }) => {
368+
filePath: ({ originalFilename, originalExtension, contentType, record }) => {
347369
console.log("🔥", JSON.stringify(record));
348370
return `aparts2/${new Date().getFullYear()}/${uuid()}/${originalFilename}.${originalExtension}`
349371
},

dev-demo/resources/description_image.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import AdminForthAdapterS3Storage from "../../adapters/adminforth-storage-adapter-amazon-s3";
2+
import AdminForthStorageAdapterLocalFilesystem from "../../adapters/adminforth-storage-adapter-local";
23
import { AdminForthResourceInput } from "../../adminforth";
34
import UploadPlugin from "../../plugins/adminforth-upload";
45
import { v1 as uuid } from "uuid";
@@ -44,7 +45,7 @@ export default {
4445
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string,
4546
s3ACL: 'public-read', // ACL which will be set to uploaded file
4647
}),
47-
48+
4849
allowedFileExtensions: [
4950
"jpg",
5051
"jpeg",

0 commit comments

Comments
 (0)