Merge branch 'dev' of github.com:smart-chain-fr/leCoffre into dev

This commit is contained in:
OxSaitama 2023-04-12 15:13:38 +02:00
commit 2a228f3da7
4 changed files with 462 additions and 11 deletions

View File

@ -18,13 +18,9 @@
###### a- Back end
`docker build -t "le-coffre-back" -f Dockerfile .`
###### b- Front end
`docker build -t "le-coffre-front" -f Dockerfiles/Dockerfile.front .`
`docker build -t "le-coffre-front" -f Dockerfile .`
#### 3) Docker Run
`docker run --env-file .env -p 3000:3000 le-coffre-back`
#### 4) Docker Compose
#### 3) Docker Compose
Docker compose allow to launch multiples images
1) **le-coffre-front**
@ -33,4 +29,6 @@ Docker compose allow to launch multiples images
> Launch your docker container with following command :
`docker compose up` -> Logs in terminal
`docker compose up -d`

View File

@ -18,7 +18,7 @@
},
"scripts": {
"build": "tsc",
"api:start": "npm run migrate && node ./dist/entries/App.js",
"api:start": "npm run migrate && npx prisma db seed && node ./dist/entries/App.js",
"start": "tsc && npm run api:start",
"dev": "nodemon -V",
"api:dev": "nodemon -V --exec 'tsc && npm run api:start'",
@ -75,6 +75,8 @@
"ts-jest": "^29.0.5"
},
"prisma": {
"schema": "src/common/databases/schema.prisma"
"schema": "src/common/databases/schema.prisma",
"seed": "ts-node src/common/databases/seeders/seeder.ts"
}
}

View File

@ -0,0 +1,450 @@
import {
Addresses,
Contacts,
Customers,
DeedHasDocumentTypes,
DeedTypeHasDocumentTypes,
DeedTypes,
Deeds,
DocumentHistory,
DocumentTypes,
Documents,
EDocumentStatus,
EFolderStatus,
EOfficeStatus,
Files,
OfficeFolderHasCustomers,
OfficeFolders,
Offices,
Users,
ECivility,
ECustomerStatus,
PrismaClient
} from "@prisma/client";
(async () => {
const prisma = new PrismaClient();
const existingData = await prisma.contacts.findFirst({ where: { email: "john.doe@example.com" } });
if (existingData) {
console.log('Seed data already exists. Skipping seeding process.');
return;
}
const randomString = () => {
const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
let result = "";
for (let i = 10; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
return result;
};
const uuidCustomer1: string = randomString();
const uuidCustomer2: string = randomString();
const uuidContact1: string = randomString();
const uuidContact2: string = randomString();
const uuidAddress1: string = randomString();
const uuidAddress2: string = randomString();
const uuidOffice1: string = randomString();
const uuidOffice2: string = randomString();
const uuidUser1: string = randomString();
const uuidUser2: string = randomString();
const uuidOfficeFolder1: string = randomString();
const uuidOfficeFolder2: string = randomString();
const uuidDeed1: string = randomString();
const uuidDeed2: string = randomString();
const uuidDeedType1: string = randomString();
const uuidDeedType2: string = randomString();
const uuidDocument1: string = randomString();
const uuidDocument2: string = randomString();
const uuidDocumentType1: string = randomString();
const uuidDocumentType2: string = randomString();
const uuidOfficeFolderHasCustomer1: string = randomString();
const uuidOfficeFolderHasCustomer2: string = randomString();
const uuidFiles1: string = randomString();
const uuidFiles2: string = randomString();
const uuidDeedHasDocumentType1: string = randomString();
const uuidDeedHasDocumentType2: string = randomString();
const uuidDeedTypeHasDocumentType1: string = randomString();
const uuidDeedTypeHasDocumentType2: string = randomString();
const uuidDocumentHistory1: string = randomString();
const uuidDocumentHistory2: string = randomString();
const customers: Customers[] = [
{
uuid: uuidCustomer1,
contact_uuid: uuidContact1,
created_at: new Date(),
updated_at: new Date(),
status: ECustomerStatus.PENDING,
},
{
uuid: uuidCustomer2,
contact_uuid: uuidContact2,
created_at: new Date(),
updated_at: new Date(),
status: ECustomerStatus.PENDING,
},
];
const addresses: Addresses[] = [
{
uuid: uuidAddress1,
address: "123 Main St",
city: "Los Angeles",
zip_code: 90001,
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidAddress2,
address: "Rue Pierre Emillion",
city: "Paris",
zip_code: 75003,
created_at: new Date(),
updated_at: new Date(),
},
];
const contacts: Contacts[] = [
{
uuid: uuidContact1,
address_uuid: uuidAddress1,
first_name: "John",
last_name: "Doe",
email: "john.doe@example.com",
phone_number: randomString(),
cell_phone_number: randomString(),
created_at: new Date(),
updated_at: new Date(),
civility: ECivility.MALE,
},
{
uuid: uuidContact2,
address_uuid: uuidAddress2,
first_name: "Jane",
last_name: "Doe",
email: "jane.doe@example.com",
phone_number: randomString(),
created_at: new Date(),
updated_at: new Date(),
cell_phone_number: randomString(),
civility: ECivility.FEMALE,
},
];
const offices: Offices[] = [
{
uuid: uuidOffice1,
idNot: randomString(),
name: "LA Office",
crpcen: randomString(),
address_uuid: uuidAddress1,
created_at: new Date(),
updated_at: new Date(),
office_status: EOfficeStatus.ACTIVATED,
},
{
uuid: uuidOffice2,
idNot: randomString(),
name: "NYC Office",
crpcen: randomString(),
address_uuid: uuidAddress2,
created_at: new Date(),
updated_at: new Date(),
office_status: EOfficeStatus.DESACTIVATED,
},
];
const users: Users[] = [
{
uuid: uuidUser1,
created_at: new Date(),
updated_at: new Date(),
idNot: randomString(),
contact_uuid: uuidContact1,
office_uuid: uuidOffice1,
},
{
uuid: uuidUser2,
created_at: new Date(),
updated_at: new Date(),
idNot: randomString(),
contact_uuid: uuidContact2,
office_uuid: uuidOffice2,
},
];
const officeFolders: OfficeFolders[] = [
{
uuid: uuidOfficeFolder1,
folder_number: randomString(),
name: "0001",
deed_uuid: uuidDeed1,
status: EFolderStatus.LIVE,
created_at: new Date(),
updated_at: new Date(),
office_uuid: uuidOffice1,
description: null,
archived_description: null,
},
{
uuid: uuidOfficeFolder2,
folder_number: randomString(),
name: "0001",
deed_uuid: uuidDeed2,
status: EFolderStatus.LIVE,
created_at: new Date(),
updated_at: new Date(),
office_uuid: uuidOffice2,
description: null,
archived_description: null,
},
];
const deeds: Deeds[] = [
{
uuid: uuidDeed1,
deed_type_uuid: uuidDeedType1,
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidDeed2,
deed_type_uuid: uuidDeedType2,
created_at: new Date(),
updated_at: new Date(),
},
];
const deedTypes: DeedTypes[] = [
{
uuid: uuidDeedType1,
name: "Acte de mariage",
archived_at: null,
description: "Acte regroupant deux personnes en mariage",
office_uuid: uuidOffice1,
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidDeedType2,
name: "Vente d'un bien immobilier",
archived_at: null,
description: "Permet de vendre un bien immobilier à une entité ou une personne physique",
office_uuid: uuidOffice2,
created_at: new Date(),
updated_at: new Date(),
},
];
const documents: Documents[] = [
{
uuid: uuidDocument1,
blockchain_anchor_uuid: null,
depositor_uuid: uuidCustomer1,
document_status: EDocumentStatus.ASKED,
folder_uuid: uuidOfficeFolder1,
type_uuid: uuidDocumentType1,
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidDocument2,
blockchain_anchor_uuid: null,
depositor_uuid: uuidCustomer2,
document_status: EDocumentStatus.ASKED,
folder_uuid: uuidOfficeFolder2,
type_uuid: uuidDocumentType2,
created_at: new Date(),
updated_at: new Date(),
},
];
const documentTypes: DocumentTypes[] = [
{
uuid: uuidDocumentType1,
archived_at: null,
name: "Acte de naissance",
office_uuid: uuidOffice1,
private_description: "Ce document est confidentiel, et ne doit pas être divulgué",
public_description: "Acte de naissance est un document officiel qui atteste de la naissance d'une personne",
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidDocumentType2,
archived_at: null,
name: "Carte d'identité",
office_uuid: uuidOffice2,
private_description: "Ce document est confidentiel, demander un recto-verso au client",
public_description: "Carte d'identité est un document officiel qui atteste de l'identité d'une personne",
created_at: new Date(),
updated_at: new Date(),
},
];
const officeFolderHasCustomers: OfficeFolderHasCustomers[] = [
{
uuid: uuidOfficeFolderHasCustomer1,
customer_uuid: uuidCustomer1,
office_folder_uuid: uuidOfficeFolder1,
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidOfficeFolderHasCustomer2,
customer_uuid: uuidCustomer2,
office_folder_uuid: uuidOfficeFolder2,
created_at: new Date(),
updated_at: new Date(),
},
];
const files: Files[] = [
{
uuid: uuidFiles1,
document_uuid: uuidDocument1,
file_path: "https://www.google1.com",
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidFiles2,
document_uuid: uuidDocument2,
file_path: "https://www.google2.com",
created_at: new Date(),
updated_at: new Date(),
},
];
const deedHasDocumentTypes: DeedHasDocumentTypes[] = [
{
uuid: uuidDeedHasDocumentType1,
deed_uuid: uuidDeed1,
document_type_uuid: uuidDocumentType1,
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidDeedHasDocumentType2,
deed_uuid: uuidDeed2,
document_type_uuid: uuidDocumentType2,
created_at: new Date(),
updated_at: new Date(),
},
];
const deedTypeHasDocumentTypes: DeedTypeHasDocumentTypes[] = [
{
uuid: uuidDeedTypeHasDocumentType1,
deed_type_uuid: uuidDeedType1,
document_type_uuid: uuidDocumentType1,
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidDeedTypeHasDocumentType2,
deed_type_uuid: uuidDeedType2,
document_type_uuid: uuidDocumentType2,
created_at: new Date(),
updated_at: new Date(),
},
];
const documentHistories: DocumentHistory[] = [
{
uuid: uuidDocumentHistory1,
document_status: EDocumentStatus.ASKED,
document_uuid: uuidDocument1,
refused_reason: "Le document n'est pas conforme",
created_at: new Date(),
updated_at: new Date(),
},
{
uuid: uuidDocumentHistory2,
document_status: EDocumentStatus.DEPOSITED,
document_uuid: uuidDocument1,
refused_reason: "Le document n'est pas conforme",
created_at: new Date(),
updated_at: new Date(),
},
];
for (const address of addresses) {
await prisma.addresses.create({data: address});
}
for (const contact of contacts) {
await prisma.contacts.create({ data: contact });
}
for (const office of offices) {
await prisma.offices.create({ data: office });
}
for (const user of users) {
await prisma.users.create({ data: user });
}
for (const customer of customers) {
await prisma.customers.create({ data: customer });
}
for (const deedType of deedTypes) {
await prisma.deedTypes.create({ data: deedType });
}
for (const deed of deeds) {
await prisma.deeds.create({ data: deed });
}
for (const officeFolder of officeFolders) {
await prisma.officeFolders.create({ data: officeFolder });
}
for (const documentType of documentTypes) {
await prisma.documentTypes.create({ data: documentType });
}
for (const document of documents) {
await prisma.documents.create({ data: document });
}
for (const file of files) {
await prisma.files.create({ data: file });
}
for (const documentHistory of documentHistories) {
await prisma.documentHistory.create({ data: documentHistory });
}
for (const officeFolderHasCustomer of officeFolderHasCustomers) {
await prisma.officeFolderHasCustomers.create({ data: officeFolderHasCustomer });
}
for (const deedHasDocumentType of deedHasDocumentTypes) {
await prisma.deedHasDocumentTypes.create({ data: deedHasDocumentType });
}
for (const deedTypeHasDocumentType of deedTypeHasDocumentTypes) {
await prisma.deedTypeHasDocumentTypes.create({ data: deedTypeHasDocumentType });
}
console.log(">MOCK DATA - Seeding completed!");
})();

View File

@ -1,8 +1,9 @@
{
"compilerOptions": {
"incremental": false,
"target": "es5",
"module": "CommonJS",
// "module": "es2022",
"target": "es2017",
"module": "commonjs",
"lib": [
"dom",
"dom.iterable",
@ -95,7 +96,7 @@
"**/*.ts",
"**/*.tsx",
"src/app/api/admin/UsersController.ts"
],
, "src/common/databases/seeders/seeder.ts" ],
"exclude": [
"node_modules"
]