78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
import { DefaultAzureCredential } from "@azure/identity";
|
|
import { BlobServiceClient, ContainerClient } from "@azure/storage-blob";
|
|
import { v4 as uuidv4 } from "uuid";
|
|
import {
|
|
createContainerSas,
|
|
listContainers,
|
|
listBlobHierarchical,
|
|
} from "../actions/azurestorage";
|
|
|
|
import { PrismaClient } from "@prisma/client";
|
|
|
|
import { consoleLogger, getIP } from "../actions";
|
|
|
|
const ShowStorage = (props) => {
|
|
const { container } = props;
|
|
|
|
return <div>hello</div>;
|
|
};
|
|
|
|
export const getServerSideProps = async (ctx) => {
|
|
const { query, req, res } = ctx;
|
|
getIP(req);
|
|
|
|
console.log(
|
|
"have these?:",
|
|
process.env.AZURE_TENANT_ID,
|
|
process.env.AZURE_CLIENT_ID,
|
|
process.env.AZURE_CLIENT_SECRET
|
|
);
|
|
const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME;
|
|
const showDebug = process.env.SHOW_DEBUG || false;
|
|
|
|
const creds = new DefaultAzureCredential();
|
|
|
|
const blobServiceClient = new BlobServiceClient(
|
|
`https://${accountName}.blob.core.windows.net`,
|
|
creds
|
|
);
|
|
|
|
console.log(
|
|
"\n=================================================",
|
|
"\nEnvironment name: " + accountName,
|
|
"\nStorage account path: " +
|
|
`https://${accountName}.blob.core.windows.net`,
|
|
"\n creds: " + JSON.stringify(creds),
|
|
"\n=================================================\n"
|
|
);
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function checkDB() {
|
|
const allUsers = await prisma.user.findMany();
|
|
console.log(
|
|
"\n=================================================\n",
|
|
"Show users in Auth DB:\n",
|
|
allUsers,
|
|
"\n=================================================\n"
|
|
);
|
|
}
|
|
|
|
showDebug &&
|
|
(checkDB()
|
|
.then(async () => {
|
|
await prisma.$disconnect();
|
|
})
|
|
.catch(async (e) => {
|
|
consoleLogger(e);
|
|
await prisma.$disconnect();
|
|
//process.exit(1);
|
|
}),
|
|
await listContainers(blobServiceClient).catch((error) =>
|
|
consoleLogger(error)
|
|
));
|
|
return { props: {} };
|
|
};
|
|
|
|
export default ShowStorage;
|