Skip to content

Commit

Permalink
Add MI_DB_SERVER_SIDE_JAVASCRIPT
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed May 18, 2024
1 parent d5ad4e6 commit 0fb2750
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 160 deletions.
1 change: 1 addition & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ MI_DB_SSL=false
MI_DB_SSL_CERT=/etc/ssl/movinin.pem
MI_DB_SSL_CA=/etc/ssl/movinin.pem
MI_DB_DEBUG=true
MI_DB_SERVER_SIDE_JAVASCRIPT=false
MI_COOKIE_SECRET=COOKIE_SECRET
MI_AUTH_COOKIE_DOMAIN=localhost
MI_JWT_SECRET=JWT_SECRET
Expand Down
261 changes: 134 additions & 127 deletions api/src/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import * as helper from '../common/helper'
* @returns {string}
*/
export const __env__ = (name: string, required?: boolean, defaultValue?: string): string => {
const value = process.env[name]
if (required && !value) {
throw new Error(`'${name} not found`)
}
if (!value) {
return defaultValue || ''
}
return String(value)
const value = process.env[name]
if (required && !value) {
throw new Error(`'${name} not found`)
}
if (!value) {
return defaultValue || ''
}
return String(value)
}

/**
Expand Down Expand Up @@ -86,6 +86,13 @@ export const DB_SSL_CA = __env__('MI_DB_SSL_CA', DB_SSL)
*/
export const DB_DEBUG = helper.StringToBoolean(__env__('MI_DB_DEBUG', false, 'false'))

/**
* Indicate whether server-side JavaScript, such as $where, $function, $accumulator and map-reduce are supported.
*
* @type {boolean}
*/
export const DB_SERVER_SIDE_JAVASCRIPT = helper.StringToBoolean(__env__('MI_DB_SERVER_SIDE_JAVASCRIPT', false, 'false'))

/**
* Cookie secret. It should at least be 32 characters long, but the longer the better.
*
Expand Down Expand Up @@ -297,24 +304,24 @@ export const ADMIN_EMAIL = __env__('MI_ADMIN_EMAIL', false)
* @extends {Document}
*/
export interface User extends Document {
agency?: Types.ObjectId
fullName: string
email: string
phone?: string
password?: string
birthDate?: Date
verified?: boolean
verifiedAt?: Date
active?: boolean
language: string
enableEmailNotifications?: boolean
avatar?: string
bio?: string
location?: string
type?: movininTypes.UserType
blacklisted?: boolean
payLater?: boolean
customerId?: string
agency?: Types.ObjectId
fullName: string
email: string
phone?: string
password?: string
birthDate?: Date
verified?: boolean
verifiedAt?: Date
active?: boolean
language: string
enableEmailNotifications?: boolean
avatar?: string
bio?: string
location?: string
type?: movininTypes.UserType
blacklisted?: boolean
payLater?: boolean
customerId?: string
}

/**
Expand All @@ -325,24 +332,24 @@ export interface User extends Document {
* @typedef {UserInfo}
*/
export interface UserInfo {
_id?: Types.ObjectId
agency?: Types.ObjectId
fullName: string
email?: string
phone?: string
password?: string
birthDate?: Date
verified?: boolean
verifiedAt?: Date
active?: boolean
language?: string
enableEmailNotifications?: boolean
avatar?: string
bio?: string
location?: string
type?: string
blacklisted?: boolean
payLater?: boolean
_id?: Types.ObjectId
agency?: Types.ObjectId
fullName: string
email?: string
phone?: string
password?: string
birthDate?: Date
verified?: boolean
verifiedAt?: Date
active?: boolean
language?: string
enableEmailNotifications?: boolean
avatar?: string
bio?: string
location?: string
type?: string
blacklisted?: boolean
payLater?: boolean
}

/**
Expand All @@ -354,20 +361,20 @@ export interface UserInfo {
* @extends {Document}
*/
export interface Booking extends Document {
agency: Types.ObjectId
location: Types.ObjectId
property: Types.ObjectId
renter: Types.ObjectId
from: Date
to: Date
status: movininTypes.BookingStatus
cancellation?: boolean
cancelRequest?: boolean
price: number
sessionId?: string
paymentIntentId?: string
customerId?: string
expireAt?: Date
agency: Types.ObjectId
location: Types.ObjectId
property: Types.ObjectId
renter: Types.ObjectId
from: Date
to: Date
status: movininTypes.BookingStatus
cancellation?: boolean
cancelRequest?: boolean
price: number
sessionId?: string
paymentIntentId?: string
customerId?: string
expireAt?: Date
}

/**
Expand All @@ -378,16 +385,16 @@ export interface Booking extends Document {
* @typedef {BookingInfo}
*/
export interface BookingInfo {
_id?: Types.ObjectId
agency: UserInfo
property: Types.ObjectId
renter: UserInfo
from: Date
to: Date
status: movininTypes.BookingStatus
cancellation?: boolean
cancelRequest?: boolean
price: number
_id?: Types.ObjectId
agency: UserInfo
property: Types.ObjectId
renter: UserInfo
from: Date
to: Date
status: movininTypes.BookingStatus
cancellation?: boolean
cancelRequest?: boolean
price: number
}

/**
Expand All @@ -399,7 +406,7 @@ export interface BookingInfo {
* @extends {Document}
*/
export interface Location extends Document {
values: Types.ObjectId[]
values: Types.ObjectId[]
}

/**
Expand All @@ -411,8 +418,8 @@ export interface Location extends Document {
* @extends {Document}
*/
export interface LocationValue extends Document {
language: string
value: string
language: string
value: string
}

/**
Expand All @@ -424,9 +431,9 @@ export interface LocationValue extends Document {
* @extends {Document}
*/
export interface LocationInfo extends Document {
_id?: Types.ObjectId
name?: string
values: LocationValue[]
_id?: Types.ObjectId
name?: string
values: LocationValue[]
}

/**
Expand All @@ -438,10 +445,10 @@ export interface LocationInfo extends Document {
* @extends {Document}
*/
export interface Notification extends Document {
user: Types.ObjectId
message: string
booking: Types.ObjectId
isRead?: boolean
user: Types.ObjectId
message: string
booking: Types.ObjectId
isRead?: boolean
}

/**
Expand All @@ -453,8 +460,8 @@ export interface Notification extends Document {
* @extends {Document}
*/
export interface NotificationCounter extends Document {
user: Types.ObjectId
count?: number
user: Types.ObjectId
count?: number
}

/**
Expand All @@ -466,28 +473,28 @@ export interface NotificationCounter extends Document {
* @extends {Document}
*/
export interface Property extends Document {
name: string
type: movininTypes.PropertyType
agency: Types.ObjectId
description: string
image: string
images?: string[]
bedrooms: number
bathrooms: number
kitchens?: number
parkingSpaces?: number,
size?: number
petsAllowed: boolean
furnished: boolean
minimumAge: number
location: Types.ObjectId
address?: string
price: number
hidden?: boolean
cancellation?: number
aircon?: boolean
available?: boolean
rentalTerm: movininTypes.RentalTerm
name: string
type: movininTypes.PropertyType
agency: Types.ObjectId
description: string
image: string
images?: string[]
bedrooms: number
bathrooms: number
kitchens?: number
parkingSpaces?: number,
size?: number
petsAllowed: boolean
furnished: boolean
minimumAge: number
location: Types.ObjectId
address?: string
price: number
hidden?: boolean
cancellation?: number
aircon?: boolean
available?: boolean
rentalTerm: movininTypes.RentalTerm
}

/**
Expand All @@ -499,26 +506,26 @@ export interface Property extends Document {
* @extends {Document}
*/
export interface PropertyInfo extends Document {
name: string
type: movininTypes.PropertyType
agency: UserInfo
description: string
image: string
images?: string[]
bedrooms: number
bathrooms: number
kitchens?: number
parkingSpaces?: number,
size: number
petsAllowed: boolean
furnished: boolean
minimumAge: number
location: Types.ObjectId
address?: string
price: number
hidden?: boolean
cancellation?: boolean
rentalTerm: movininTypes.RentalTerm
name: string
type: movininTypes.PropertyType
agency: UserInfo
description: string
image: string
images?: string[]
bedrooms: number
bathrooms: number
kitchens?: number
parkingSpaces?: number,
size: number
petsAllowed: boolean
furnished: boolean
minimumAge: number
location: Types.ObjectId
address?: string
price: number
hidden?: boolean
cancellation?: boolean
rentalTerm: movininTypes.RentalTerm
}

/**
Expand All @@ -530,8 +537,8 @@ export interface PropertyInfo extends Document {
* @extends {Document}
*/
export interface PushToken extends Document {
user: Types.ObjectId
token: string
user: Types.ObjectId
token: string
}

/**
Expand All @@ -543,7 +550,7 @@ export interface PushToken extends Document {
* @extends {Document}
*/
export interface Token extends Document {
user: Types.ObjectId
token: string
expireAt?: Date
user: Types.ObjectId
token: string
expireAt?: Date
}
Loading

0 comments on commit 0fb2750

Please sign in to comment.