npm install
copy ".env.sample" file and add your mysql login
Don't forget to add port for localhost
import the reset-db
make npm start to the console for launch the server.
npm start
email:[email protected] password: JimmyGanci email: [email protected] password: BastienT email:[email protected] password:autorepare24
.post("api/vehicules/upload")
.post("api/users/upload")
.post("api/pros/upload")
Result data : https://"your_host_minio"/"your_bucket_minio"//invoice//your_files_name.png
Example client:
const handleUpload = async (e) => { e.preventDefault(); const formData = new FormData(); formData.append("file", file); const upload = await axios.post( "http://localhost:8000/api/vehicules/upload", formData, { withCredentials: true } ); console.log(upload); if (upload) { const postVehicule = await axios.post( "http://localhost:8000/api/vehicules/", { immat: immat, registration_date: "2015-10-21T00:00:00.000Z", url_vehiculeRegistration: upload.data, id_modelId: parseInt(model), id_typeId: parseInt(type), id_userId: parseInt(user), }, { withCredentials: true, } ); console.log(postVehicule.data); } };
.get("/api/vehicules/all")
[ { "immat": "CL-940-TE", "registration_date": "2007-10-21T00:00:00.000Z", "model_id_model": 5, "user_id_user": 2, "types_id_type": 2, "url_vehiculeRegistration": "" }, { "immat": "CL-950-TE", "registration_date": "2012-10-30T00:00:00.000Z", "model_id_model": 1, "user_id_user": 1, "types_id_type": 1, "url_vehiculeRegistration": "" }, { "immat": "CP-900-TE", "registration_date": "2016-10-30T00:00:00.000Z", "model_id_model": 2, "user_id_user": 2, "types_id_type": 1, "url_vehiculeRegistration": "" }, { "immat": "ML-967-TT", "registration_date": "2021-10-21T00:00:00.000Z", "model_id_model": 300, "user_id_user": 1, "types_id_type": 1, "url_vehiculeRegistration": "" } ]
.get("/api/vehicules/:immat)
.get("/api/vehicules/CL-940-TE)
{ "immat": "CL-940-TE", "registration_date": "2007-10-21T00:00:00.000Z", "model_id_model": 5, "user_id_user": 2, "types_id_type": 2, "url_vehiculeRegistration": "" }
.get("/api/vehicules/user/:idUser)
.get("/api/vehicules/user/2)
.get("/api/vehicules/:immat/model)
.get("/api/vehicules/HY-567-HY/model)
{ "id_model": 5, "code": "3.2CL", "name": " - 3.2CL", "id_brand": 1 }
.get("/api/vehicules/:immat/brand)
.get("/api/vehicules/HY-678-HY/brand)
{ "id_brand": 1, "code": "ACURA", "name": "Acura" }
.post("/api/vehicules")
.put("api/vehicule/:id)
.delete("api/vehicule/:id)
get("api/users/all")
Results:
{ "id_user": 1, "firstname": "Buddy", "lastname": "Cadet", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$IaW4RanaMVmzJt4tbipbBQ$LzRQanarVEivgJMXXJO2uhlNrhVe89rRLNlvyL0UDf4", "address": "Angresse", "phone": "06-78-76-78-76", "postal_code": 40000, "city": "Angresse" }, { "id_user": 2, "firstname": "Buddy", "lastname": "Ganci", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$KcDNxFFRs2+0CQTCSCjalQ$7eEVEdmO0HZUWZPXzV5Zq5mRHAEhS/YkkZQxG0GphHg", "address": "rue de la croquette", "phone": "06-78-76-78-76", "postal_code": 40130, "city": "Capbreton" }, { "id_user": 3, "firstname": "mika", "lastname": "dut", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$Sq9xsyQtq+xLrjR/vJIsnQ$KgSIEqAUA+ljIs8lbE8fklCVNWj1XLAIWJJMPhEDQ44", "address": "rue de la grotte", "phone": "06-78-76-78-76", "postal_code": 93000, "city": "Paris" },
.get("api/users/:id")
.get("/api/users/2")
Results:
{ "id_user": 2, "firstname": "Buddy", "lastname": "Ganci", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$KcDNxFFRs2+0CQTCSCjalQ$7eEVEdmO0HZUWZPXzV5Zq5mRHAEhS/YkkZQxG0GphHg", "address": "rue de la croquette", "phone": "06-78-76-78-76", "postal_code": 40130, "city": "Capbreton" }
.get("api/users/vehicule/:idBrand")
.get("/api/users/vehicules/1")
Results:
{ { "immat": "MM-967-TT", "registration_date": "2021-10-21T00:00:00.000Z", "model_id_model": 100, "user_id_user": 1, "types_id_type": 1, "url_vehiculeRegistration": "" }, { "immat": "MZ-877-UU", "registration_date": "2005-10-21T00:00:00.000Z", "model_id_model": 100, "user_id_user": 1, "types_id_type": 1, "url_vehiculeRegistration": "" } }
.get("api/users/pros/:idUser")
.get("/api/users/pros/1")
Results:
{ [] }
.get("api/users/:idUser/prosDeleted/:idPros")
.get("/api/users/2/prosDeleted/1")
Results:
{ [] }
.get("api/users/all?lastname=?")
.get("/api/users/all?lastname=cade")
Results:
{ { "id_user": 1, "firstname": "Buddy", "lastname": "Cadet", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$BAySd1UMW6s38RbnPUjlgA$MQyZYxKXX1H379J9jbOKz7p0Lh43T1SbbWtLYPaAIVU", "address": "Angresse", "phone": "06-78-76-78-76", "postal_code": 40000, "city": "Angresse" } }
.get("api/users/all?postal_code=?")
.get("/api/users/all?postal_code=40130")
Results:
{ "id_user": 2, "firstname": "Buddy", "lastname": "Ganci", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$KcDNxFFRs2+0CQTCSCjalQ$7eEVEdmO0HZUWZPXzV5Zq5mRHAEhS/YkkZQxG0GphHg", "address": "rue de la croquette", "phone": "06-78-76-78-76", "postal_code": 40130, "city": "Capbreton" }
.get("api/users/all?city=?")
.get("/api/users/all?city=cap")
Results:
{ "id_user": 2, "firstname": "Buddy", "lastname": "Ganci", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$KcDNxFFRs2+0CQTCSCjalQ$7eEVEdmO0HZUWZPXzV5Zq5mRHAEhS/YkkZQxG0GphHg", "address": "rue de la croquette", "phone": "06-78-76-78-76", "postal_code": 40130, "city": "Capbreton" }
.get("api/users/")
.get("/api/users/")
Results:
{ "id_user": 10, "firstname": "matthieu", "lastname": "dubo", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$cOJ+Ee/IHuVXjBdmf828bg$kqeTBkm/N/NIwgFJE38giaVaW3sB67L2brD6hSLUCck", "address": "rue de la benne", "phone": "06-78-76-78-76", "postal_code": 40100, "city": "Saubrigue" }
.get("api/users/pro/:idUser")
.get("/api/users/pro/4")
Results:
{ "id_pros": 1, "name": "Bernadin auto", "email": "[email protected]", "hashedPassword": "bon", "adress": "78 avenue du temps", "postal_code": 33130, "city": "Bordeaux", "siret": 76549864, "phone": "06-56-57-57-76" }, { "id_pros": 2, "name": "auto", "email": "[email protected]", "hashedPassword": "bon", "adress": "78 avenue du temps", "postal_code": 33130, "city": "Bordeaux", "siret": 76549864, "phone": "06-56-57-57-76" }
.get("api/users/:idUser")
.get("/api/users/1")
Results:
{ "id_user": 1, "firstname": "Buddy", "lastname": "Cadet", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$BAySd1UMW6s38RbnPUjlgA$MQyZYxKXX1H379J9jbOKz7p0Lh43T1SbbWtLYPaAIVU", "address": "Angresse", "phone": "06-78-76-78-76", "postal_code": 40000, "city": "Angresse" }
.get("api/users/:idUser")
.get("/api/users/1")
Results:
"Buddy deleted"
.get("/api/appointment")
Results:
[ { "userId": 1, "prosId": 2, "date": "2022-03-01T00:00:00.000Z", "comment": "entretien 10000" }, { "userId": 1, "prosId": 4, "date": "2022-03-01T00:00:00.000Z", "comment": "entretien 10000" } ]
.get("/api/appointment/user/:userId/pros/prosId")
.get("/api/appointment/user/1/pros/4")
Results:
{ "userId": 1, "prosId": 4, "date": "2022-03-01T00:00:00.000Z", "comment": "entretien 10000" }
.get("/api/appointment/user/userId")
.get("/api/appointment/user/1")
Results:
[ { "id_pros": 2, "name": "Pneu123", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$0OZViyOU5ZO2c23P2lNAew$3KqrgZwFerxgsH7xkC1NXvK3GukRJfUpvhTnV4Wru2E", "address": "78 avenue du pneu", "postal_code": 40130, "city": "Capbreton", "siret": "23456545432334", "phone": "06-90-76-57-76" }, { "id_pros": 4, "name": "Garage des Pins", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$UD6EO+ouPfx7JQyJjRIvow$1joKcpBw9bCupaGiR4Ge7CGl2xBp9Q/jb37ZdGccKdg", "address": "78 avenue des pins", "postal_code": 40130, "city": "Capbreton", "siret": "23456545432334", "phone": "06-90-76-57-76" } ]
.get("/api/appointment/pros/prosId")
.get("/api/appointment/pros/4")
Results:
[ { "id_user": 1, "firstname": "Buddy", "lastname": "Cadet", "email": "[email protected]", "hashedPassword": "$argon2id$v=19$m=65536,t=5,p=1$wQyXp/JtaEONYdoAFu31sA$oC+59EHM3yybccAS9mqtsPVMRZBHd91SiNCf7EGtLno", "address": "Angresse", "phone": "06-78-76-78-76", "postal_code": 40000, "city": "Angresse" } ]
.get("/api/appointment/pros")
.get("/api/appointment/pros")
Results:
{ "userId": 1, "prosId": 4, "date": "2022-03-01T00:00:00.000Z", "comment": "entretien 10000" }
.get("/api/appointment/pros")
.get("/api/appointment/pros")
Results:
{ "userId": 1, "prosId": 4, "date": "2022-03-01T00:00:00.000Z", "comment": "entretien 10000" }
.get("/api/appointment/user/1/pros/1")
.get("/api/appointment/user/userId/pros/prosId")
Results:
Appointment of Tue Mar 01 2022 01:00:00 GMT+0100 (heure normale d’Europe centrale) with pros Id 1 deleted