Skip to content

Commit

Permalink
Remove validate-address controller and related schema, refactor locat…
Browse files Browse the repository at this point in the history
…ion schema and types
  • Loading branch information
jamalsoueidan committed Mar 15, 2024
1 parent bac4add commit d39cb0d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/functions/location/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./get-coordinates";
export * from "./get-travel-time";
export * from "./validate-address";
23 changes: 0 additions & 23 deletions src/functions/location/controllers/validate-address.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/functions/location/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./controllers";
export * from "./location.model";
export * from "./location.schema";
export * from "./location.types";
export * from "./schemas";
2 changes: 1 addition & 1 deletion src/functions/location/location.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Model, model } from "mongoose";
import { ILocationDocument, LocationMongooseSchema } from "./schemas";
import { ILocationDocument, LocationMongooseSchema } from "./location.schema";

export const LocationModel = model<ILocationDocument, Model<ILocationDocument>>(
"location",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import mongoose, { Document, Model } from "mongoose";
import {
Location,
LocationOriginTypes,
LocationTypes,
} from "../location.types";
import { Location, LocationOriginTypes, LocationTypes } from "./location.types";

export interface ILocation extends Location {
geoLocation: {
Expand All @@ -22,6 +18,7 @@ export const LocationMongooseSchema = new mongoose.Schema<
Model<ILocationDocument>
>(
{
isDefault: { type: Boolean, default: false },
locationType: {
type: String,
enum: [LocationTypes.DESTINATION, LocationTypes.ORIGIN],
Expand Down Expand Up @@ -85,6 +82,10 @@ export const LocationMongooseSchema = new mongoose.Schema<
type: String,
unique: true,
},
deletedAt: {
type: Date,
default: null,
},
},
{ timestamps: true }
);
8 changes: 7 additions & 1 deletion src/functions/location/location.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { z } from "zod";
import { GidFormat, NumberOrStringType } from "~/library/zod";
import {
BooleanOrStringType,
GidFormat,
NumberOrStringType,
} from "~/library/zod";

export enum LocationTypes {
ORIGIN = "origin",
Expand All @@ -11,6 +15,7 @@ export enum LocationOriginTypes {
COMMERCIAL = "commercial",
}
export const LocationZodSchema = z.object({
isDefault: BooleanOrStringType,
locationType: z.nativeEnum(LocationTypes),
customerId: GidFormat,
name: z.string(),
Expand All @@ -22,6 +27,7 @@ export const LocationZodSchema = z.object({
minDriveDistance: NumberOrStringType,
maxDriveDistance: NumberOrStringType,
startFee: NumberOrStringType,
deletedAt: z.coerce.date().optional(),
});

export type Location = z.infer<typeof LocationZodSchema>;
1 change: 0 additions & 1 deletion src/functions/location/schemas/index.ts

This file was deleted.

0 comments on commit d39cb0d

Please sign in to comment.