Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed May 18, 2024
1 parent 3dc08d1 commit 067320e
Show file tree
Hide file tree
Showing 45 changed files with 1,534 additions and 1,204 deletions.
193 changes: 88 additions & 105 deletions api/package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"@types/jest": "^29.5.12",
"@types/jsonwebtoken": "^9.0.6",
"@types/multer": "^1.4.11",
"@types/node": "^20.12.11",
"@types/node": "^20.12.12",
"@types/nodemailer": "^6.4.15",
"@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.8",
"@types/validator": "^13.11.9",
"@types/validator": "^13.11.10",
"babel-jest": "^29.7.0",
"babel-plugin-add-import-extension": "^1.6.0",
"babel-plugin-module-resolver": "^5.0.2",
Expand All @@ -50,26 +50,26 @@
"i18n-js": "^4.4.3",
"jest": "^29.7.0",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.3.4",
"mongoose": "^8.4.0",
"multer": "^1.4.5-lts.1",
"nocache": "^4.0.0",
"nodemailer": "^6.9.13",
"rimraf": "^5.0.5",
"stripe": "^15.6.0",
"rimraf": "^5.0.7",
"stripe": "^15.7.0",
"supertest": "^7.0.0",
"typescript": "^5.4.5",
"uuid": "^9.0.1",
"validator": "^13.12.0",
"winston": "^3.13.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.1",
"nodemon": "^3.1.0",
"npm-check-updates": "^16.14.20",
"tsx": "^4.9.4"
"tsx": "^4.10.4"
}
}
4 changes: 2 additions & 2 deletions api/src/common/databaseHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const initialize = async (): Promise<boolean> => {
const bookingIndex = bookingIndexes.find((index: any) => index.name === BOOKING_EXPIRE_AT_INDEX_NAME && index.expireAfterSeconds !== env.BOOKING_EXPIRE_AT)
if (bookingIndex) {
try {
await Booking.collection.dropIndex(bookingIndex.name)
await Booking.collection.dropIndex(bookingIndex.name!)
} catch (err) {
logger.error('Failed dropping Booking TTL index', err)
} finally {
Expand All @@ -129,7 +129,7 @@ export const initialize = async (): Promise<boolean> => {
const tokenIndex = tokenIndexes.find((index: any) => index.name.includes(TOKEN_EXPIRE_AT_INDEX_NAME))
if (tokenIndex) {
try {
await Token.collection.dropIndex(tokenIndex.name)
await Token.collection.dropIndex(tokenIndex.name!)
} catch (err) {
logger.error('Failed dropping Token TTL index', err)
} finally {
Expand Down
4 changes: 2 additions & 2 deletions api/src/controllers/bookingController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ export const checkout = async (req: Request, res: Response) => {
html: `<p>
${i18n.t('HELLO')}${user.fullName},<br><br>
${i18n.t('ACCOUNT_ACTIVATION_LINK')}<br><br>
${helper.joinURL(env.FRONTEND_HOST, 'activate')}/?u=${encodeURIComponent(user._id.toString())}&e=${encodeURIComponent(user.email)}&t=${encodeURIComponent(token.token)}<br><br>
${helper.joinURL(env.FRONTEND_HOST, 'activate')}/?u=${encodeURIComponent(user.id)}&e=${encodeURIComponent(user.email)}&t=${encodeURIComponent(token.token)}<br><br>
${i18n.t('REGARDS')}<br>
</p>`,
}
await mailHelper.sendMail(mailOptions)

body.booking.driver = user._id.toString()
body.booking.driver = user.id
} else {
user = await User.findById(body.booking.driver)
}
Expand Down
10 changes: 5 additions & 5 deletions api/src/controllers/carController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export const getCars = async (req: Request, res: Response) => {
const size = Number.parseInt(req.params.size, 10)
const suppliers = body.suppliers.map((id) => new mongoose.Types.ObjectId(id))
const {
fuel,
carType,
gearbox,
mileage,
deposit,
Expand All @@ -412,8 +412,8 @@ export const getCars = async (req: Request, res: Response) => {
$and: [{ name: { $regex: keyword, $options: options } }, { supplier: { $in: suppliers } }],
}

if (fuel) {
$match.$and!.push({ type: { $in: fuel } })
if (carType) {
$match.$and!.push({ type: { $in: carType } })
}

if (gearbox) {
Expand Down Expand Up @@ -564,7 +564,7 @@ export const getFrontendCars = async (req: Request, res: Response) => {
const suppliers = body.suppliers.map((id) => new mongoose.Types.ObjectId(id))
const pickupLocation = new mongoose.Types.ObjectId(body.pickupLocation)
const {
fuel,
carType,
gearbox,
mileage,
deposit,
Expand All @@ -574,7 +574,7 @@ export const getFrontendCars = async (req: Request, res: Response) => {
$and: [
{ supplier: { $in: suppliers } },
{ locations: pickupLocation },
{ available: true }, { type: { $in: fuel } },
{ available: true }, { type: { $in: carType } },
{ gearbox: { $in: gearbox } },
],
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/controllers/stripeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ export const checkCheckoutSession = async (req: Request, res: Response) => {
}
i18n.locale = supplier.language
let message = i18n.t('BOOKING_PAID_NOTIFICATION')
await bookingController.notify(user, booking._id.toString(), supplier, message)
await bookingController.notify(user, booking.id, supplier, message)

// Notify admin
const admin = !!env.ADMIN_EMAIL && await User.findOne({ email: env.ADMIN_EMAIL, type: bookcarsTypes.UserType.Admin })
if (admin) {
i18n.locale = admin.language
message = i18n.t('BOOKING_PAID_NOTIFICATION')
await bookingController.notify(user, booking._id.toString(), admin, message)
await bookingController.notify(user, booking.id, admin, message)
}

return res.sendStatus(200)
Expand Down
6 changes: 3 additions & 3 deletions api/src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const create = async (req: Request, res: Response) => {
${helper.joinURL(
user.type === bookcarsTypes.UserType.User ? env.FRONTEND_HOST : env.BACKEND_HOST,
'activate',
)}/?u=${encodeURIComponent(user._id)}&e=${encodeURIComponent(user.email)}&t=${encodeURIComponent(token.token)}<br><br>
)}/?u=${encodeURIComponent(user.id)}&e=${encodeURIComponent(user.email)}&t=${encodeURIComponent(token.token)}<br><br>
${i18n.t('REGARDS')}<br>
</p>`,
}
Expand Down Expand Up @@ -347,7 +347,7 @@ export const resend = async (req: Request, res: Response) => {
${helper.joinURL(
user.type === bookcarsTypes.UserType.User ? env.FRONTEND_HOST : env.BACKEND_HOST,
reset ? 'reset-password' : 'activate',
)}/?u=${encodeURIComponent(user._id)}&e=${encodeURIComponent(user.email)}&t=${encodeURIComponent(token.token)}<br><br>
)}/?u=${encodeURIComponent(user.id)}&e=${encodeURIComponent(user.email)}&t=${encodeURIComponent(token.token)}<br><br>
${i18n.t('REGARDS')}<br>
</p>`,
}
Expand Down Expand Up @@ -478,7 +478,7 @@ export const signin = async (req: Request, res: Response) => {
const token = jwt.sign(payload, env.JWT_SECRET, options)

const loggedUser: bookcarsTypes.User = {
_id: user._id,
_id: user.id,
email: user.email,
fullName: user.fullName,
language: user.language,
Expand Down
8 changes: 7 additions & 1 deletion api/src/models/Car.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ const carSchema = new Schema<env.Car>(
},
type: {
type: String,
enum: [bookcarsTypes.CarType.Diesel, bookcarsTypes.CarType.Gasoline],
enum: [
bookcarsTypes.CarType.Diesel,
bookcarsTypes.CarType.Gasoline,
bookcarsTypes.CarType.Electric,
bookcarsTypes.CarType.Hybrid,
bookcarsTypes.CarType.PlugInHybrid,
],
required: [true, "can't be blank"],
},
gearbox: {
Expand Down
6 changes: 3 additions & 3 deletions api/tests/car.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ describe('POST /api/cars/:page/:size', () => {

const payload: bookcarsTypes.GetCarsPayload = {
suppliers: [SUPPLIER2_ID],
fuel: [bookcarsTypes.CarType.Diesel, bookcarsTypes.CarType.Gasoline],
carType: [bookcarsTypes.CarType.Diesel, bookcarsTypes.CarType.Gasoline],
gearbox: [bookcarsTypes.GearboxType.Manual, bookcarsTypes.GearboxType.Automatic],
mileage: [bookcarsTypes.Mileage.Limited, bookcarsTypes.Mileage.Unlimited],
availability: [bookcarsTypes.Availablity.Available, bookcarsTypes.Availablity.Unavailable],
Expand All @@ -386,7 +386,7 @@ describe('POST /api/cars/:page/:size', () => {
expect(res.statusCode).toBe(200)
expect(res.body[0].resultData.length).toBeGreaterThan(0)

payload.fuel = undefined
payload.carType = undefined
payload.gearbox = undefined
payload.mileage = undefined
payload.availability = undefined
Expand Down Expand Up @@ -493,7 +493,7 @@ describe('POST /api/frontend-cars/:page/:size', () => {
const payload: bookcarsTypes.GetCarsPayload = {
suppliers: [SUPPLIER2_ID],
pickupLocation: LOCATION2_ID,
fuel: [bookcarsTypes.CarType.Diesel, bookcarsTypes.CarType.Gasoline],
carType: [bookcarsTypes.CarType.Diesel, bookcarsTypes.CarType.Gasoline],
gearbox: [bookcarsTypes.GearboxType.Manual, bookcarsTypes.GearboxType.Automatic],
mileage: [bookcarsTypes.Mileage.Limited, bookcarsTypes.Mileage.Unlimited],
deposit: -1,
Expand Down
8 changes: 4 additions & 4 deletions api/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ describe('Test database initialization', () => {

if (tokenIndex) {
const { expireAfterSeconds } = tokenIndex
await Token.collection.dropIndex(tokenIndex.name)
await createTokenIndex(expireAfterSeconds + 1)
await Token.collection.dropIndex(tokenIndex.name!)
await createTokenIndex(expireAfterSeconds! + 1)
await delay()
res = await databaseHelper.initialize()
expect(res).toBeTruthy()
Expand All @@ -69,8 +69,8 @@ describe('Test database initialization', () => {

if (bookingIndex) {
const { expireAfterSeconds } = bookingIndex
await Booking.collection.dropIndex(bookingIndex.name)
await createBookingIndex(expireAfterSeconds + 1)
await Booking.collection.dropIndex(bookingIndex.name!)
await createBookingIndex(expireAfterSeconds! + 1)
await delay()
res = await databaseHelper.initialize()
expect(res).toBeTruthy()
Expand Down
2 changes: 1 addition & 1 deletion api/tests/miscellaneous.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Test User phone validation', () => {
try {
const user = new User(USER)
await user.save()
userId = user._id
userId = user.id
user.phone = 'unknown'
await user.save()
} catch (err) {
Expand Down
Loading

0 comments on commit 067320e

Please sign in to comment.