refactoring , dockerizing
This commit is contained in:
@@ -5,7 +5,10 @@ class StrapiApi{
|
||||
}
|
||||
|
||||
public getHomePage(){
|
||||
|
||||
console.info('Get Home Page');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const api = new StrapiApi();
|
||||
export default api;
|
||||
@@ -48,85 +48,85 @@ const customers = [
|
||||
},
|
||||
];
|
||||
|
||||
const invoices: any[] = [
|
||||
// {
|
||||
// customer_id: customers[0].id,
|
||||
// amount: 15795,
|
||||
// status: 'pending',
|
||||
// date: '2022-12-06',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[1].id,
|
||||
// amount: 20348,
|
||||
// status: 'pending',
|
||||
// date: '2022-11-14',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[4].id,
|
||||
// amount: 3040,
|
||||
// status: 'paid',
|
||||
// date: '2022-10-29',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[3].id,
|
||||
// amount: 44800,
|
||||
// status: 'paid',
|
||||
// date: '2023-09-10',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[5].id,
|
||||
// amount: 34577,
|
||||
// status: 'pending',
|
||||
// date: '2023-08-05',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[2].id,
|
||||
// amount: 54246,
|
||||
// status: 'pending',
|
||||
// date: '2023-07-16',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[0].id,
|
||||
// amount: 666,
|
||||
// status: 'pending',
|
||||
// date: '2023-06-27',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[3].id,
|
||||
// amount: 32545,
|
||||
// status: 'paid',
|
||||
// date: '2023-06-09',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[4].id,
|
||||
// amount: 1250,
|
||||
// status: 'paid',
|
||||
// date: '2023-06-17',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[5].id,
|
||||
// amount: 8546,
|
||||
// status: 'paid',
|
||||
// date: '2023-06-07',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[1].id,
|
||||
// amount: 500,
|
||||
// status: 'paid',
|
||||
// date: '2023-08-19',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[5].id,
|
||||
// amount: 8945,
|
||||
// status: 'paid',
|
||||
// date: '2023-06-03',
|
||||
// },
|
||||
// {
|
||||
// customer_id: customers[2].id,
|
||||
// amount: 1000,
|
||||
// status: 'paid',
|
||||
// date: '2022-06-05',
|
||||
// },
|
||||
const invoices = [
|
||||
{
|
||||
customer_id: customers[0].id,
|
||||
amount: 15795,
|
||||
status: 'pending',
|
||||
date: '2022-12-06',
|
||||
},
|
||||
{
|
||||
customer_id: customers[1].id,
|
||||
amount: 20348,
|
||||
status: 'pending',
|
||||
date: '2022-11-14',
|
||||
},
|
||||
{
|
||||
customer_id: customers[4].id,
|
||||
amount: 3040,
|
||||
status: 'paid',
|
||||
date: '2022-10-29',
|
||||
},
|
||||
{
|
||||
customer_id: customers[3].id,
|
||||
amount: 44800,
|
||||
status: 'paid',
|
||||
date: '2023-09-10',
|
||||
},
|
||||
{
|
||||
customer_id: customers[5].id,
|
||||
amount: 34577,
|
||||
status: 'pending',
|
||||
date: '2023-08-05',
|
||||
},
|
||||
{
|
||||
customer_id: customers[2].id,
|
||||
amount: 54246,
|
||||
status: 'pending',
|
||||
date: '2023-07-16',
|
||||
},
|
||||
{
|
||||
customer_id: customers[0].id,
|
||||
amount: 666,
|
||||
status: 'pending',
|
||||
date: '2023-06-27',
|
||||
},
|
||||
{
|
||||
customer_id: customers[3].id,
|
||||
amount: 32545,
|
||||
status: 'paid',
|
||||
date: '2023-06-09',
|
||||
},
|
||||
{
|
||||
customer_id: customers[4].id,
|
||||
amount: 1250,
|
||||
status: 'paid',
|
||||
date: '2023-06-17',
|
||||
},
|
||||
{
|
||||
customer_id: customers[5].id,
|
||||
amount: 8546,
|
||||
status: 'paid',
|
||||
date: '2023-06-07',
|
||||
},
|
||||
{
|
||||
customer_id: customers[1].id,
|
||||
amount: 500,
|
||||
status: 'paid',
|
||||
date: '2023-08-19',
|
||||
},
|
||||
{
|
||||
customer_id: customers[5].id,
|
||||
amount: 8945,
|
||||
status: 'paid',
|
||||
date: '2023-06-03',
|
||||
},
|
||||
{
|
||||
customer_id: customers[2].id,
|
||||
amount: 1000,
|
||||
status: 'paid',
|
||||
date: '2022-06-05',
|
||||
},
|
||||
];
|
||||
|
||||
const revenue = [
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import bcrypt from 'bcrypt';
|
||||
import { invoices, customers, revenue, users } from './placeholder-data';
|
||||
|
||||
import strapiApi from "@/app/api/strapi/strapi-api";
|
||||
|
||||
// const client = await connectionPool.connect();
|
||||
|
||||
import connectionPool from "../../db/db";
|
||||
@@ -108,16 +110,23 @@ export async function GET() {
|
||||
// 'Uncomment this file and remove this line. You can delete this file when you are finished.',
|
||||
// });
|
||||
try {
|
||||
console.info("get request")
|
||||
strapiApi.getHomePage();
|
||||
|
||||
console.info("begin")
|
||||
await connectionPool.query(`BEGIN`);
|
||||
await seedUsers();
|
||||
await seedCustomers();
|
||||
// await seedInvoices();
|
||||
// await seedRevenue();
|
||||
await seedInvoices();
|
||||
await seedRevenue();
|
||||
await connectionPool.query(`COMMIT`);
|
||||
console.info('Database seeded successfully')
|
||||
|
||||
return Response.json({ message: 'Database seeded successfully' });
|
||||
} catch (error) {
|
||||
await connectionPool.query(`ROLLBACK`);
|
||||
console.info("error in seed")
|
||||
|
||||
return Response.json({ error }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user