Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change to mapbox #23

Merged
merged 5 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 50 additions & 47 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
# development | production
NODE_ENV=development

PORT=3000

API_VERSION=v1.0.0

# Examples: all, ["error", "info", "log", "migration", "query", "schema", "warn"]
SYSTEM_LOG_INFO=all

# JWT Authentication Strategy
JWT_SECRET=e267edf0f1a4a62d496a6738aed12266fd1f17136f1d019c88b57e5439855307458b0a2652a5bb6246f636ff265ad2be7c193d155ce46df6e7287de143b2f55b
JWT_EXPIRES_IN=1d

# TypeORM config
TYPEORM_HOST=localhost
TYPEORM_PORT=5432
TYPEORM_USERNAME=postgres
TYPEORM_PASSWORD=postgres
TYPEORM_DATABASE=MapSorter

# Google OAuth2
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URL=

# Cloudinary
CLOUDINARY_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=

# Local Storage
STORAGE_TYPE=local
LOCAL_STORAGE_PATH=/uploads/media
LIMIT_FILE_UPLOAD=10
MAX_FILE_SIZE=5242880 # 5mb

# Google Maps API
GOOGLE_MAPS_API_KEY=

# Sentry
SENTRY_DSN=

# Discord bot
DISCORD_WEBHOOK=
DISCORD_BOT_NAME=
DISCORD_BOT_AVATAR_URL=
# development | production
NODE_ENV=development

PORT=3000

API_VERSION=v1.0.0

# Examples: all, ["error", "info", "log", "migration", "query", "schema", "warn"]
SYSTEM_LOG_INFO=all

# JWT Authentication Strategy
JWT_SECRET=e267edf0f1a4a62d496a6738aed12266fd1f17136f1d019c88b57e5439855307458b0a2652a5bb6246f636ff265ad2be7c193d155ce46df6e7287de143b2f55b
JWT_EXPIRES_IN=1d

# TypeORM config
TYPEORM_HOST=localhost
TYPEORM_PORT=5432
TYPEORM_USERNAME=postgres
TYPEORM_PASSWORD=postgres
TYPEORM_DATABASE=MapSorter

# Google OAuth2
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URL=

# Cloudinary
CLOUDINARY_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=

# Local Storage
STORAGE_TYPE=local
LOCAL_STORAGE_PATH=/uploads/media
LIMIT_FILE_UPLOAD=10
MAX_FILE_SIZE=5242880 # 5mb

# Google Maps API
GOOGLE_MAPS_API_KEY=

# MapBox API
MAPBOX_TOKEN=

# Sentry
SENTRY_DSN=

# Discord bot
DISCORD_WEBHOOK=
DISCORD_BOT_NAME=
DISCORD_BOT_AVATAR_URL=
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@googlemaps/google-maps-services-js": "^3.3.42",
"@googlemaps/google-maps-services-js": "^3.4.0",
"@mapbox/polyline": "^1.2.1",
"@nestjs/bull": "^10.0.1",
"@nestjs/common": "^9.2.0",
Expand All @@ -55,7 +55,7 @@
"@types/multer": "^1.4.7",
"amqp-connection-manager": "^4.1.14",
"amqplib": "^0.10.3",
"axios": "^1.6.1",
"axios": "^1.7.7",
"bull": "^4.11.4",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/maps/infra/restful-api/map.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class MapController {
tags: ['maps'],
operationId: 'optimized-route',
summary: 'Optimized Route',
description: 'Get optimized route with geocoded waypoints and routes',
description: 'Get optimized route with geocode waypoints and routes',
})
@ApiResponse({
status: HttpStatus.OK,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/maps/infra/restful-api/map.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { ApiConfigService } from '@shared/services/api-config.service';
import { MapController } from './map.controller';
import { GoogleMapService } from '@modules/maps/services/providers/google-map.service';
import { GeocodeUseCase } from '@modules/maps/usecases/geocode/geocode.usecase';
import { GetOptimizedRouteUseCase } from '@modules/maps/usecases/get-optimized-route/get-optimized-route.usecase';
import { TypeOrmRouteRepository } from '@modules/maps/repos/implementations/typeorm.route.repository';
import { SaveRouteUseCase } from '@modules/maps/usecases/save-route/save-route.usecase';
import { MapBoxService } from '@modules/maps/services/providers/mapbox.service';

@Module({
imports: [
Expand All @@ -32,7 +32,7 @@ import { SaveRouteUseCase } from '@modules/maps/usecases/save-route/save-route.u
SaveRouteUseCase,
{
provide: 'IMapService',
useClass: GoogleMapService,
useClass: MapBoxService,
},
{
provide: 'IRouteRepository',
Expand Down
2 changes: 1 addition & 1 deletion src/modules/maps/services/constant.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const WAYPOINT_LIMIT = 23;
export const WAYPOINT_LIMIT = 12;
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IDirectionResponseData {
geocoded_waypoints?: any[];
routes?: any[];
status: string;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { IDirectionsRequest } from '../../directions-request.interface';
import { ApiKeyParams } from '@modules/maps/services/api-key-param.interface';

export class MapBoxDirectionsRequest implements IDirectionsRequest {
params: {
origin: {
lat: number;
lng: number;
};
destination: {
lat: number;
lng: number;
};
waypoints?: {
lat: number;
lng: number;
}[];
optimize?: boolean;
} & ApiKeyParams;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IDirectionsResponse } from '../../directions-response.interface';

export interface WaypointsResponseData {
distance?: number;
name?: string;
location: [number, number];
waypoint_index: number;
}

export class MapBoxDirectionsResponse implements IDirectionsResponse {
data: {
status: string;
routes: {
waypoints?: WaypointsResponseData;
legs: [];
overview_polyline: string;
}[];
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ApiKeyParams } from '@modules/maps/services/api-key-param.interface';
import { IGeocodeRequest } from '../../geocode-request.interface';
export class MapBoxGeocodeRequest implements IGeocodeRequest {
params: {
address?: string;
} & ApiKeyParams;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {
IGeocodeResponse,
IGeocodeResponseData,
} from '../../geocode-response.interface';

export class MapBoxGeocodeResponse implements IGeocodeResponse {
data: IGeocodeResponseData;
}
Loading