Add new car modification options to CarModifications component, including performance upgrades for engine, exhaust, suspension, and brakes. Update Customer model to include address and car year fields, and implement pre-save hook for updatedAt timestamp. Enhance customer routes with authentication middleware and improved error handling.

This commit is contained in:
Alvin
2025-06-10 10:09:38 +02:00
parent 7b394b92d9
commit cefd020db6
4 changed files with 435 additions and 39 deletions

View File

@@ -3,21 +3,34 @@ const mongoose = require('mongoose');
const customerSchema = new mongoose.Schema({
name: {
type: String,
required: true
required: true,
trim: true
},
email: {
type: String,
required: true,
unique: true
unique: true,
trim: true,
lowercase: true
},
phone: {
type: String
type: String,
required: true,
trim: true
},
carDetails: {
make: String,
model: String,
year: Number,
modifications: [String]
address: {
type: String,
trim: true
},
carModel: {
type: String,
required: true,
trim: true
},
carYear: {
type: String,
required: true,
trim: true
},
createdAt: {
type: Date,
@@ -29,4 +42,10 @@ const customerSchema = new mongoose.Schema({
}
});
// Update the updatedAt timestamp before saving
customerSchema.pre('save', function(next) {
this.updatedAt = Date.now();
next();
});
module.exports = mongoose.model('Customer', customerSchema);