added db storage check debug
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
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\n\n=================================================\n",
|
||||
"Environment name:" + accountName,
|
||||
"\n=================================================\n"
|
||||
);
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function checkDB() {
|
||||
const allUsers = await prisma.user.findMany();
|
||||
console.log(
|
||||
"\n\n\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;
|
||||
Reference in New Issue
Block a user