🎯 MapView v2.0 - Global Deployment Ready

 MAJOR FEATURES:
• Auto-zoom intelligence với smart bounds fitting
• Enhanced 3D GPS markers với pulsing effects
• Professional route display với 6-layer rendering
• Status-based parking icons với availability indicators
• Production-ready build optimizations

🗺️ AUTO-ZOOM FEATURES:
• Smart bounds fitting cho GPS + selected parking
• Adaptive padding (50px) cho visual balance
• Max zoom control (level 16) để tránh quá gần
• Dynamic centering khi không có selection

🎨 ENHANCED VISUALS:
• 3D GPS marker với multi-layer pulse effects
• Advanced parking icons với status colors
• Selection highlighting với animation
• Dimming system cho non-selected items

🛣️ ROUTE SYSTEM:
• OpenRouteService API integration
• Multi-layer route rendering (glow, shadow, main, animated)
• Real-time distance & duration calculation
• Visual route info trong popup

📱 PRODUCTION READY:
• SSR safe với dynamic imports
• Build errors resolved
• Global deployment via Vercel
• Optimized performance

🌍 DEPLOYMENT:
• Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app
• Bundle size: 22.8 kB optimized
• Global CDN distribution
• HTTPS enabled

💾 VERSION CONTROL:
• MapView-v2.0.tsx backup created
• MAPVIEW_VERSIONS.md documentation
• Full version history tracking
This commit is contained in:
2025-07-20 19:52:16 +07:00
parent 3203463a6a
commit c65cc97a33
64624 changed files with 7199453 additions and 6462 deletions

41
.gitignore vendored
View File

@@ -1,41 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

510
DEPLOYMENT.md Normal file
View File

@@ -0,0 +1,510 @@
# 🚀 Deployment Guide
This guide covers different deployment strategies for the Smart Parking Finder application.
## 📋 Table of Contents
1. [Development Deployment](#development-deployment)
2. [Production Deployment](#production-deployment)
3. [Cloud Deployment Options](#cloud-deployment-options)
4. [Environment Configuration](#environment-configuration)
5. [Monitoring & Logging](#monitoring--logging)
6. [Backup & Recovery](#backup--recovery)
7. [Troubleshooting](#troubleshooting)
## 🛠️ Development Deployment
### Quick Start
```bash
# 1. Clone and setup
git clone <repository-url>
cd smart-parking-finder
./setup.sh
# 2. Start development environment
docker-compose up -d
# 3. Start development servers
cd frontend && npm run dev &
cd backend && npm run start:dev &
```
### Development Services
- **Frontend**: http://localhost:3000
- **Backend API**: http://localhost:3001
- **PostgreSQL**: localhost:5432
- **Redis**: localhost:6379
- **Valhalla**: http://localhost:8002
- **pgAdmin**: http://localhost:5050 (with `--profile tools`)
## 🏭 Production Deployment
### Docker Compose Production
```bash
# 1. Create production environment
cp docker-compose.yml docker-compose.prod.yml
# 2. Update production configuration
# Edit docker-compose.prod.yml with production settings
# 3. Deploy
docker-compose -f docker-compose.prod.yml up -d
```
### Production Docker Compose
```yaml
version: '3.8'
services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.prod
ports:
- "80:3000"
environment:
- NODE_ENV=production
- NEXT_PUBLIC_API_URL=https://api.yourparking.com
restart: unless-stopped
backend:
build:
context: ./backend
dockerfile: Dockerfile.prod
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- DATABASE_URL=${DATABASE_URL}
- REDIS_URL=${REDIS_URL}
- JWT_SECRET=${JWT_SECRET}
restart: unless-stopped
nginx:
image: nginx:alpine
ports:
- "443:443"
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/ssl:/etc/nginx/ssl
depends_on:
- frontend
- backend
restart: unless-stopped
postgres:
image: postgis/postgis:15-3.3
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7-alpine
volumes:
- redis_data:/data
restart: unless-stopped
valhalla:
build: ./valhalla
volumes:
- valhalla_data:/data
restart: unless-stopped
volumes:
postgres_data:
redis_data:
valhalla_data:
```
## ☁️ Cloud Deployment Options
### 1. DigitalOcean Droplet
**Recommended for small to medium deployments**
```bash
# 1. Create Droplet (4GB RAM minimum for Valhalla)
doctl compute droplet create parking-app \
--size s-2vcpu-4gb \
--image ubuntu-22-04-x64 \
--region sgp1
# 2. Install Docker
ssh root@your-droplet-ip
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
# 3. Deploy application
git clone <repository-url>
cd smart-parking-finder
docker-compose -f docker-compose.prod.yml up -d
```
### 2. AWS EC2 + RDS
**Recommended for scalable production**
```bash
# 1. Launch EC2 instance (t3.medium minimum)
# 2. Setup RDS PostgreSQL with PostGIS
# 3. Setup ElastiCache Redis
# 4. Deploy application containers
# User data script for EC2:
#!/bin/bash
yum update -y
yum install -y docker git
systemctl start docker
systemctl enable docker
usermod -a -G docker ec2-user
# Clone and deploy
git clone <repository-url> /opt/parking-app
cd /opt/parking-app
docker-compose -f docker-compose.aws.yml up -d
```
### 3. Google Cloud Platform
**Using Cloud Run and Cloud SQL**
```bash
# 1. Build and push images
gcloud builds submit --tag gcr.io/PROJECT_ID/parking-frontend ./frontend
gcloud builds submit --tag gcr.io/PROJECT_ID/parking-backend ./backend
# 2. Deploy to Cloud Run
gcloud run deploy parking-frontend \
--image gcr.io/PROJECT_ID/parking-frontend \
--platform managed \
--region asia-southeast1
gcloud run deploy parking-backend \
--image gcr.io/PROJECT_ID/parking-backend \
--platform managed \
--region asia-southeast1
```
### 4. Kubernetes Deployment
**For large-scale deployments**
```yaml
# k8s/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: parking-finder
---
# k8s/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: parking-finder
data:
DATABASE_HOST: "postgres-service"
REDIS_HOST: "redis-service"
VALHALLA_URL: "http://valhalla-service:8002"
---
# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
namespace: parking-finder
spec:
replicas: 3
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: your-registry/parking-frontend:latest
ports:
- containerPort: 3000
envFrom:
- configMapRef:
name: app-config
```
## 🔧 Environment Configuration
### Production Environment Variables
```bash
# .env.production
NODE_ENV=production
# Database
DATABASE_URL=postgresql://user:pass@db-host:5432/parking_db
POSTGRES_SSL=true
# Redis
REDIS_URL=redis://redis-host:6379
REDIS_SSL=true
# Security
JWT_SECRET=your-super-secure-jwt-secret-256-bit
JWT_EXPIRATION=1h
CORS_ORIGIN=https://yourparking.com
# APIs
VALHALLA_URL=http://valhalla:8002
MAP_TILES_URL=https://tile.openstreetmap.org/{z}/{x}/{y}.png
# Monitoring
SENTRY_DSN=your-sentry-dsn
LOG_LEVEL=info
# Performance
REDIS_CACHE_TTL=3600
DB_POOL_SIZE=10
API_RATE_LIMIT=100
```
### SSL Configuration
```nginx
# nginx/nginx.conf
server {
listen 443 ssl http2;
server_name yourparking.com;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
# Frontend
location / {
proxy_pass http://frontend:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# Backend API
location /api {
proxy_pass http://backend:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# WebSocket support
location /ws {
proxy_pass http://backend:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
## 📊 Monitoring & Logging
### Docker Logging
```yaml
# docker-compose.monitoring.yml
version: '3.8'
services:
prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
volumes:
- grafana_data:/var/lib/grafana
node-exporter:
image: prom/node-exporter
ports:
- "9100:9100"
volumes:
grafana_data:
```
### Application Monitoring
```typescript
// backend/src/monitoring/metrics.ts
import { createPrometheusMetrics } from '@prometheus/client';
export const metrics = {
httpRequests: new Counter({
name: 'http_requests_total',
help: 'Total HTTP requests',
labelNames: ['method', 'route', 'status']
}),
routeCalculationTime: new Histogram({
name: 'route_calculation_duration_seconds',
help: 'Route calculation duration',
buckets: [0.1, 0.5, 1, 2, 5]
}),
databaseQueries: new Counter({
name: 'database_queries_total',
help: 'Total database queries',
labelNames: ['operation', 'table']
})
};
```
## 💾 Backup & Recovery
### Database Backup
```bash
#!/bin/bash
# backup.sh
# Variables
BACKUP_DIR="/opt/backups"
DATE=$(date +%Y%m%d_%H%M%S)
DB_NAME="parking_db"
# Create backup
docker-compose exec postgres pg_dump \
-U parking_user \
-h localhost \
-d $DB_NAME \
--clean \
--if-exists \
--create \
> "$BACKUP_DIR/db_backup_$DATE.sql"
# Compress backup
gzip "$BACKUP_DIR/db_backup_$DATE.sql"
# Keep only last 7 days
find $BACKUP_DIR -name "db_backup_*.sql.gz" -mtime +7 -delete
echo "Backup completed: db_backup_$DATE.sql.gz"
```
### Automated Backup with Cron
```bash
# Add to crontab: crontab -e
# Daily backup at 2 AM
0 2 * * * /opt/parking-app/scripts/backup.sh >> /var/log/backup.log 2>&1
# Weekly full system backup
0 3 * * 0 /opt/parking-app/scripts/full-backup.sh >> /var/log/backup.log 2>&1
```
## 🔍 Troubleshooting
### Common Issues
1. **Valhalla not starting**
```bash
# Check OSM data
ls -la valhalla/custom_files/
# Check logs
docker-compose logs valhalla
# Verify memory allocation
docker stats valhalla
```
2. **Database connection issues**
```bash
# Test connection
docker-compose exec postgres psql -U parking_user -d parking_db
# Check network
docker network ls
docker network inspect parking-finder_parking-network
```
3. **High memory usage**
```bash
# Monitor services
docker stats
# Optimize Valhalla cache
# Edit valhalla.json: reduce max_cache_size
```
### Health Checks
```bash
#!/bin/bash
# health-check.sh
echo "=== Health Check ==="
# Frontend
curl -f http://localhost:3000 || echo "❌ Frontend down"
# Backend
curl -f http://localhost:3001/health || echo "❌ Backend down"
# Database
docker-compose exec postgres pg_isready -U parking_user || echo "❌ Database down"
# Redis
docker-compose exec redis redis-cli ping || echo "❌ Redis down"
# Valhalla
curl -f http://localhost:8002/status || echo "❌ Valhalla down"
echo "=== Check complete ==="
```
### Performance Optimization
```yaml
# docker-compose.optimized.yml
services:
backend:
deploy:
resources:
limits:
memory: 1G
cpus: '0.5'
reservations:
memory: 512M
cpus: '0.25'
valhalla:
deploy:
resources:
limits:
memory: 4G
cpus: '2'
reservations:
memory: 2G
cpus: '1'
```
---
For additional support, refer to the [main README](../README.md) or contact the development team.

750
DEVELOPMENT.md Normal file
View File

@@ -0,0 +1,750 @@
# 🛠️ Development Guide
This guide covers the development workflow, coding standards, and best practices for the Smart Parking Finder application.
## 📋 Table of Contents
1. [Development Setup](#development-setup)
2. [Project Structure](#project-structure)
3. [Development Workflow](#development-workflow)
4. [Coding Standards](#coding-standards)
5. [Testing Strategy](#testing-strategy)
6. [Debugging](#debugging)
7. [Performance Guidelines](#performance-guidelines)
8. [Contributing](#contributing)
## 🚀 Development Setup
### Prerequisites
- Node.js 18+ and npm
- Docker and Docker Compose
- Git
- VS Code (recommended)
### Initial Setup
```bash
# 1. Clone repository
git clone <repository-url>
cd smart-parking-finder
# 2. Run automated setup
./setup.sh
# 3. Start development environment
docker-compose up -d
# 4. Install dependencies
cd frontend && npm install
cd ../backend && npm install
# 5. Start development servers
npm run dev:all # Starts both frontend and backend
```
### Environment Configuration
```bash
# .env.development
NODE_ENV=development
# Database
DATABASE_URL=postgresql://parking_user:parking_pass@localhost:5432/parking_db
# Redis
REDIS_URL=redis://localhost:6379
# Valhalla
VALHALLA_URL=http://localhost:8002
# Development
DEBUG=true
LOG_LEVEL=debug
HOT_RELOAD=true
```
## 📁 Project Structure
```
smart-parking-finder/
├── frontend/ # Next.js frontend application
│ ├── src/
│ │ ├── app/ # App router pages
│ │ ├── components/ # Reusable UI components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── services/ # API service layers
│ │ ├── types/ # TypeScript type definitions
│ │ └── utils/ # Utility functions
│ ├── public/ # Static assets
│ └── tests/ # Frontend tests
├── backend/ # NestJS backend application
│ ├── src/
│ │ ├── modules/ # Feature modules
│ │ ├── common/ # Shared utilities
│ │ ├── config/ # Configuration files
│ │ └── database/ # Database related files
│ └── tests/ # Backend tests
├── valhalla/ # Routing engine setup
├── scripts/ # Development scripts
└── docs/ # Documentation
```
### Frontend Architecture
```
frontend/src/
├── app/ # Next.js 14 App Router
│ ├── (dashboard)/ # Route groups
│ ├── api/ # API routes
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/ # UI Components
│ ├── ui/ # Base UI components
│ ├── forms/ # Form components
│ ├── map/ # Map-related components
│ └── parking/ # Parking-specific components
├── hooks/ # Custom hooks
│ ├── useGeolocation.ts
│ ├── useParking.ts
│ └── useRouting.ts
├── services/ # API services
│ ├── api.ts # Base API client
│ ├── parkingService.ts
│ └── routingService.ts
└── types/ # TypeScript definitions
├── parking.ts
├── routing.ts
└── user.ts
```
### Backend Architecture
```
backend/src/
├── modules/ # Feature modules
│ ├── auth/ # Authentication
│ ├── parking/ # Parking management
│ ├── routing/ # Route calculation
│ └── users/ # User management
├── common/ # Shared code
│ ├── decorators/ # Custom decorators
│ ├── filters/ # Exception filters
│ ├── guards/ # Auth guards
│ └── pipes/ # Validation pipes
├── config/ # Configuration
│ ├── database.config.ts
│ ├── redis.config.ts
│ └── app.config.ts
└── database/ # Database files
├── migrations/ # Database migrations
├── seeds/ # Seed data
└── entities/ # TypeORM entities
```
## 🔄 Development Workflow
### Git Workflow
```bash
# 1. Create feature branch
git checkout -b feature/parking-search-improvements
# 2. Make changes with atomic commits
git add .
git commit -m "feat(parking): add distance-based search filtering"
# 3. Push and create PR
git push origin feature/parking-search-improvements
```
### Commit Message Convention
```
type(scope): description
Types:
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- style: Code style changes
- refactor: Code refactoring
- test: Adding tests
- chore: Maintenance tasks
Examples:
feat(map): add real-time parking availability indicators
fix(routing): resolve incorrect distance calculations
docs(api): update parking endpoint documentation
```
### Development Scripts
```json
{
"scripts": {
"dev": "next dev",
"dev:backend": "cd backend && npm run start:dev",
"dev:all": "concurrently \"npm run dev\" \"npm run dev:backend\"",
"build": "next build",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",
"type-check": "tsc --noEmit"
}
}
```
## 📝 Coding Standards
### TypeScript Configuration
```json
// tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"lib": ["dom", "dom.iterable", "es6"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@/components/*": ["./src/components/*"],
"@/services/*": ["./src/services/*"],
"@/types/*": ["./src/types/*"]
}
}
}
```
### ESLint Configuration
```json
// .eslintrc.json
{
"extends": [
"next/core-web-vitals",
"@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-function-return-type": "warn",
"prefer-const": "error",
"no-var": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
```
### Code Style Guidelines
#### Frontend Components
```typescript
// ✅ Good: Functional component with proper typing
interface ParkingListProps {
parkingLots: ParkingLot[];
onSelect: (lot: ParkingLot) => void;
loading?: boolean;
}
export const ParkingList: React.FC<ParkingListProps> = ({
parkingLots,
onSelect,
loading = false
}) => {
const [selectedId, setSelectedId] = useState<string | null>(null);
const handleSelect = useCallback((lot: ParkingLot) => {
setSelectedId(lot.id);
onSelect(lot);
}, [onSelect]);
if (loading) {
return <LoadingSpinner />;
}
return (
<div className="parking-list">
{parkingLots.map((lot) => (
<ParkingCard
key={lot.id}
lot={lot}
isSelected={selectedId === lot.id}
onClick={() => handleSelect(lot)}
/>
))}
</div>
);
};
```
#### Backend Services
```typescript
// ✅ Good: Service with proper error handling and typing
@Injectable()
export class ParkingService {
constructor(
@InjectRepository(ParkingLot)
private readonly parkingRepository: Repository<ParkingLot>,
private readonly cacheService: CacheService,
private readonly logger: Logger
) {}
async findNearbyParking(
dto: FindNearbyParkingDto
): Promise<ParkingLot[]> {
try {
const cacheKey = `nearby:${dto.latitude}:${dto.longitude}:${dto.radius}`;
// Check cache first
const cached = await this.cacheService.get<ParkingLot[]>(cacheKey);
if (cached) {
return cached;
}
// Query database with spatial index
const lots = await this.parkingRepository
.createQueryBuilder('lot')
.where(
'ST_DWithin(lot.location::geography, ST_Point(:lng, :lat)::geography, :radius)',
{
lng: dto.longitude,
lat: dto.latitude,
radius: dto.radius
}
)
.andWhere('lot.isActive = :isActive', { isActive: true })
.orderBy(
'ST_Distance(lot.location::geography, ST_Point(:lng, :lat)::geography)',
'ASC'
)
.limit(dto.limit || 20)
.getMany();
// Cache results
await this.cacheService.set(cacheKey, lots, 300); // 5 minutes
return lots;
} catch (error) {
this.logger.error('Failed to find nearby parking', error);
throw new InternalServerErrorException('Failed to find nearby parking');
}
}
}
```
## 🧪 Testing Strategy
### Test Structure
```
tests/
├── unit/ # Unit tests
├── integration/ # Integration tests
├── e2e/ # End-to-end tests
└── fixtures/ # Test data
```
### Frontend Testing
```typescript
// components/ParkingList.test.tsx
import { render, screen, fireEvent } from '@testing-library/react';
import { ParkingList } from './ParkingList';
import { mockParkingLots } from '../../../tests/fixtures/parking';
describe('ParkingList', () => {
const mockOnSelect = jest.fn();
beforeEach(() => {
mockOnSelect.mockClear();
});
it('renders parking lots correctly', () => {
render(
<ParkingList
parkingLots={mockParkingLots}
onSelect={mockOnSelect}
/>
);
expect(screen.getByText('Central Mall Parking')).toBeInTheDocument();
expect(screen.getByText('$5/hour')).toBeInTheDocument();
});
it('calls onSelect when parking lot is clicked', () => {
render(
<ParkingList
parkingLots={mockParkingLots}
onSelect={mockOnSelect}
/>
);
fireEvent.click(screen.getByText('Central Mall Parking'));
expect(mockOnSelect).toHaveBeenCalledWith(mockParkingLots[0]);
});
it('shows loading spinner when loading', () => {
render(
<ParkingList
parkingLots={[]}
onSelect={mockOnSelect}
loading={true}
/>
);
expect(screen.getByRole('status')).toBeInTheDocument();
});
});
```
### Backend Testing
```typescript
// parking/parking.service.spec.ts
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { ParkingService } from './parking.service';
import { ParkingLot } from './entities/parking-lot.entity';
import { mockRepository } from '../../tests/mocks/repository.mock';
describe('ParkingService', () => {
let service: ParkingService;
let repository: any;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
ParkingService,
{
provide: getRepositoryToken(ParkingLot),
useValue: mockRepository,
},
],
}).compile();
service = module.get<ParkingService>(ParkingService);
repository = module.get(getRepositoryToken(ParkingLot));
});
describe('findNearbyParking', () => {
it('should return nearby parking lots', async () => {
const mockLots = [/* mock data */];
repository.createQueryBuilder().getMany.mockResolvedValue(mockLots);
const result = await service.findNearbyParking({
latitude: 1.3521,
longitude: 103.8198,
radius: 1000,
});
expect(result).toEqual(mockLots);
expect(repository.createQueryBuilder).toHaveBeenCalled();
});
});
});
```
### Integration Testing
```typescript
// parking/parking.controller.integration.spec.ts
import { Test } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../app.module';
describe('ParkingController (Integration)', () => {
let app: INestApplication;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleRef.createNestApplication();
await app.init();
});
it('/parking/nearby (POST)', () => {
return request(app.getHttpServer())
.post('/parking/nearby')
.send({
latitude: 1.3521,
longitude: 103.8198,
radius: 1000,
})
.expect(200)
.expect((res) => {
expect(res.body).toHaveProperty('data');
expect(Array.isArray(res.body.data)).toBe(true);
});
});
afterAll(async () => {
await app.close();
});
});
```
## 🐛 Debugging
### Frontend Debugging
```typescript
// Development debugging utilities
export const debugLog = (message: string, data?: any): void => {
if (process.env.NODE_ENV === 'development') {
console.log(`[DEBUG] ${message}`, data);
}
};
// React Developer Tools
// Component debugging
export const ParkingDebugger: React.FC = () => {
const [parkingLots, setParkingLots] = useLocalStorage('debug:parking', []);
useEffect(() => {
// Log component updates
debugLog('ParkingDebugger mounted');
return () => {
debugLog('ParkingDebugger unmounted');
};
}, []);
return (
<div className="debug-panel">
<h3>Parking Debug Info</h3>
<pre>{JSON.stringify(parkingLots, null, 2)}</pre>
</div>
);
};
```
### Backend Debugging
```typescript
// Logger configuration
import { Logger } from '@nestjs/common';
@Injectable()
export class DebugService {
private readonly logger = new Logger(DebugService.name);
logRequest(req: Request, res: Response, next: NextFunction): void {
const { method, originalUrl, body, query } = req;
this.logger.debug(`${method} ${originalUrl}`, {
body,
query,
timestamp: new Date().toISOString(),
});
next();
}
logDatabaseQuery(query: string, parameters?: any[]): void {
this.logger.debug('Database Query', {
query,
parameters,
timestamp: new Date().toISOString(),
});
}
}
```
### VS Code Debug Configuration
```json
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Frontend",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/frontend",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"]
},
{
"name": "Debug Backend",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/backend",
"program": "${workspaceFolder}/backend/dist/main.js",
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"restart": true,
"protocol": "inspector"
}
]
}
```
## ⚡ Performance Guidelines
### Frontend Performance
```typescript
// Use React.memo for expensive components
export const ParkingMap = React.memo<ParkingMapProps>(({
parkingLots,
onMarkerClick
}) => {
// Component implementation
});
// Optimize re-renders with useMemo
const filteredLots = useMemo(() => {
return parkingLots.filter(lot =>
lot.availableSpaces > 0 &&
lot.distance <= maxDistance
);
}, [parkingLots, maxDistance]);
// Virtual scrolling for large lists
import { FixedSizeList as List } from 'react-window';
const VirtualizedParkingList: React.FC = ({ items }) => (
<List
height={600}
itemCount={items.length}
itemSize={120}
itemData={items}
>
{ParkingRow}
</List>
);
```
### Backend Performance
```typescript
// Database query optimization
@Injectable()
export class OptimizedParkingService {
// Use spatial indexes
async findNearbyOptimized(dto: FindNearbyParkingDto): Promise<ParkingLot[]> {
return this.parkingRepository.query(`
SELECT *
FROM parking_lots
WHERE ST_DWithin(
location::geography,
ST_Point($1, $2)::geography,
$3
)
AND available_spaces > 0
ORDER BY location <-> ST_Point($1, $2)
LIMIT $4
`, [dto.longitude, dto.latitude, dto.radius, dto.limit]);
}
// Implement caching
@Cacheable('parking:nearby', 300) // 5 minutes
async findNearbyCached(dto: FindNearbyParkingDto): Promise<ParkingLot[]> {
return this.findNearbyOptimized(dto);
}
}
// Connection pooling
export const databaseConfig: TypeOrmModuleOptions = {
type: 'postgres',
url: process.env.DATABASE_URL,
extra: {
max: 20, // maximum number of connections
connectionTimeoutMillis: 2000,
idleTimeoutMillis: 30000,
},
};
```
## 🤝 Contributing
### Pull Request Process
1. **Fork and Clone**
```bash
git clone https://github.com/your-username/smart-parking-finder.git
cd smart-parking-finder
git remote add upstream https://github.com/original/smart-parking-finder.git
```
2. **Create Feature Branch**
```bash
git checkout -b feature/your-feature-name
```
3. **Development**
- Follow coding standards
- Write tests for new features
- Update documentation
4. **Submit PR**
- Ensure all tests pass
- Update CHANGELOG.md
- Provide clear description
### Code Review Guidelines
- **Code Quality**: Follows TypeScript best practices
- **Testing**: Adequate test coverage (>80%)
- **Performance**: No performance regressions
- **Documentation**: Updated documentation
- **Security**: No security vulnerabilities
### Issue Templates
```markdown
## Bug Report
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
What you expected to happen.
**Screenshots**
If applicable, add screenshots.
**Environment:**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
```
---
For more information, see the [README](../README.md) and [Technical Specification](../TECHNICAL_SPECIFICATION.md).

104
MAPVIEW_VERSIONS.md Normal file
View File

@@ -0,0 +1,104 @@
# 📦 MAPVIEW VERSION HISTORY
## 🎯 MapView v2.0 - Global Deployment Ready
**Ngày:** 20/07/2025
**File:** `MapView-v2.0.tsx`
### ✨ **TÍNH NĂNG CHÍNH:**
#### 🗺️ **Auto-Zoom Intelligence**
- **Smart Bounds Fitting:** Tự động zoom để hiển thị vừa GPS và parking đã chọn
- **Adaptive Padding:** 50px padding cho visual balance tối ưu
- **Max Zoom Control:** Giới hạn zoom level 16 để tránh quá gần
- **Dynamic Centering:** Center trên user location khi không chọn parking
#### 🎨 **Enhanced Visual Design**
- **3D GPS Marker:** Multi-layer pulsing với gradient effects
- **Advanced Parking Icons:** Status-based colors với availability indicators
- **Enhanced Selection Effects:** Highlighted states với animation
- **Dimming System:** Non-selected parkings được làm mờ khi có selection
#### 🛣️ **Professional Route Display**
- **Multi-layer Route:** 6 layers với glow, shadow, main, animated dash
- **Real-time Calculation:** OpenRouteService API integration
- **Visual Route Info:** Distance & duration display trong popup
- **Animated Flow:** CSS animations cho movement effect
#### 📱 **Production Optimizations**
- **SSR Safe:** Dynamic imports cho Leaflet components
- **Performance:** Optimized re-renders và memory management
- **Error Handling:** Robust route calculation với fallback
- **Global Ready:** Deployed và tested trên Vercel
### 🔧 **TECHNICAL SPECS:**
```typescript
// Core Features
- Auto-zoom với fitBounds()
- Enhanced marker systems
- Route calculation API
- Status-based styling
- Animation frameworks
// Performance
- Dynamic imports
- Optimized effects
- Memory management
- Error boundaries
```
### 🌍 **DEPLOYMENT STATUS:**
-**Production Build:** Successful
-**Vercel Deploy:** https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app
-**Global Access:** Worldwide availability
-**HTTPS Ready:** Secure connections
-**CDN Optimized:** Fast loading globally
### 🎯 **USE CASES:**
1. **Smart Parking Discovery:** Auto-zoom to show user + nearby parking
2. **Route Planning:** Visual route với distance/time info
3. **Status Monitoring:** Real-time parking availability
4. **Global Access:** Use from anywhere in the world
### 📊 **PERFORMANCE METRICS:**
- **Bundle Size:** 22.8 kB optimized
- **First Load:** 110 kB total
- **Build Time:** ~1 minute
- **Global Latency:** <200ms via CDN
---
## 🏗️ **PREVIOUS VERSIONS:**
### MapView v1.x
- Basic Leaflet integration
- Simple markers
- Local development only
- No auto-zoom features
---
## 🚀 **DEPLOYMENT COMMANDS:**
```bash
# Local development
npm run dev
# Production build
npm run build
# Global deployment
./deploy-vercel.sh
# Alternative global access
./start-global.sh # ngrok tunnel
```
## 📝 **NOTES:**
- Version 2.0 marks the first globally accessible release
- All major build errors resolved for production
- Auto-zoom feature is the key differentiator
- Route calculation adds professional UX
- Enhanced visuals provide premium feel
**Status:** PRODUCTION READY - GLOBALLY ACCESSIBLE

274
README.md
View File

@@ -1,36 +1,266 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). # 🚗 Smart Parking Finder
## Getting Started A modern web application for finding and navigating to available parking spaces using OpenStreetMap and Valhalla routing engine.
First, run the development server: ## 🏗️ Project Structure
```bash ```
npm run dev smart-parking-finder/
# or ├── frontend/ # Next.js frontend application
yarn dev │ ├── src/
# or │ │ ├── app/ # App router pages
pnpm dev │ │ ├── components/ # Reusable React components
# or │ │ ├── hooks/ # Custom React hooks
bun dev │ │ ├── services/ # API services
│ │ ├── types/ # TypeScript type definitions
│ │ └── utils/ # Utility functions
│ ├── public/ # Static assets
│ └── package.json
├── backend/ # NestJS backend API
│ ├── src/
│ │ ├── modules/ # Feature modules
│ │ ├── common/ # Shared utilities
│ │ ├── config/ # Configuration
│ │ └── database/ # Database setup
│ └── package.json
├── valhalla/ # Valhalla routing engine
│ ├── Dockerfile
│ ├── valhalla.json # Valhalla configuration
│ └── osm-data/ # OpenStreetMap data files
├── docker-compose.yml # Development environment
├── docker-compose.prod.yml # Production environment
└── README.md
``` ```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. ## 🚀 Quick Start
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. ### Prerequisites
- Docker & Docker Compose
- Node.js 18+
- PostgreSQL with PostGIS
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. ### Development Setup
## Learn More 1. **Clone the repository**
```bash
git clone <repository-url>
cd smart-parking-finder
```
To learn more about Next.js, take a look at the following resources: 2. **Start infrastructure services**
```bash
docker-compose up -d postgres redis valhalla
```
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 3. **Install dependencies**
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. ```bash
# Frontend
cd frontend && npm install
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! # Backend
cd ../backend && npm install
```
## Deploy on Vercel 4. **Environment setup**
```bash
# Copy environment files
cp frontend/.env.example frontend/.env.local
cp backend/.env.example backend/.env
```
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 5. **Database setup**
```bash
# Run migrations
cd backend && npm run migration:run
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. # Seed initial data
npm run seed:run
```
6. **Start development servers**
```bash
# Terminal 1 - Backend
cd backend && npm run start:dev
# Terminal 2 - Frontend
cd frontend && npm run dev
```
Visit `http://localhost:3000` to see the application.
## 🔧 Technology Stack
### Frontend
- **Next.js 14** - React framework with App Router
- **TypeScript** - Type safety and better DX
- **Tailwind CSS** - Utility-first CSS framework
- **React Leaflet** - Interactive maps
- **React Query** - Server state management
- **Zustand** - Client state management
### Backend
- **NestJS** - Scalable Node.js framework
- **TypeORM** - Database ORM with TypeScript
- **PostgreSQL + PostGIS** - Spatial database
- **Redis** - Caching and session storage
- **Swagger** - API documentation
### Infrastructure
- **Docker** - Containerization
- **Valhalla** - Open-source routing engine
- **CloudFlare** - CDN and security
## 🌟 Features
### ✅ Implemented
- User location detection via GPS
- Interactive map with OpenStreetMap
- Nearby parking lot search
- Real-time availability display
- Route calculation with Valhalla
- Turn-by-turn navigation
- Responsive design
- PWA support
### 🚧 In Progress
- User authentication
- Parking reservations
- Payment integration
- Push notifications
### 📋 Planned
- Offline mode
- Multi-language support
- EV charging station integration
- AI-powered parking predictions
## 📊 API Documentation
### Parking Endpoints
- `GET /api/parking/nearby` - Find nearby parking lots
- `GET /api/parking/:id` - Get parking lot details
- `POST /api/parking/:id/reserve` - Reserve a parking space
### Routing Endpoints
- `POST /api/routes/calculate` - Calculate route between points
- `GET /api/routes/:id` - Get route details
- `POST /api/routes/:id/optimize` - Optimize existing route
### User Endpoints
- `POST /api/auth/login` - User authentication
- `GET /api/users/profile` - Get user profile
- `POST /api/users/favorites` - Add favorite parking lot
Full API documentation available at `/api/docs` when running the backend.
## 🧪 Testing
### Frontend Testing
```bash
cd frontend
npm run test # Unit tests
npm run test:e2e # End-to-end tests
npm run test:coverage # Coverage report
```
### Backend Testing
```bash
cd backend
npm run test # Unit tests
npm run test:e2e # Integration tests
npm run test:cov # Coverage report
```
## 🚀 Deployment
### Development
```bash
docker-compose up -d
```
### Production
```bash
docker-compose -f docker-compose.prod.yml up -d
```
### Environment Variables
```bash
# Frontend (.env.local)
NEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_MAP_TILES_URL=https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
# Backend (.env)
DATABASE_URL=postgresql://user:password@localhost:5432/parking_db
REDIS_URL=redis://localhost:6379
VALHALLA_URL=http://localhost:8002
JWT_SECRET=your-jwt-secret
```
## 📈 Performance
### Metrics
- Page load time: < 2 seconds
- Route calculation: < 3 seconds
- Map rendering: < 1 second
- API response time: < 500ms
### Optimization
- Code splitting for optimal bundle size
- Image optimization with Next.js
- Redis caching for frequent requests
- Database query optimization
- CDN for static assets
## 🔒 Security
### Implemented
- HTTPS enforcement
- JWT authentication
- Rate limiting
- Input validation
- SQL injection prevention
- XSS protection
### Best Practices
- Regular dependency updates
- Security headers
- Environment variable protection
- API key rotation
- Database encryption
## 🤝 Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request
### Development Guidelines
- Follow TypeScript best practices
- Write tests for new features
- Update documentation
- Follow conventional commits
- Ensure code passes linting
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 🆘 Support
- 📧 Email: support@smartparking.com
- 💬 Discord: [Join our community](https://discord.gg/smartparking)
- 🐛 Issues: [GitHub Issues](https://github.com/your-org/smart-parking-finder/issues)
- 📖 Docs: [Documentation](https://docs.smartparking.com)
## 🙏 Acknowledgments
- OpenStreetMap for map data
- Valhalla project for routing engine
- PostGIS for spatial database capabilities
- All contributors and beta testers
---
Made with by the Smart Parking Team

420
TECHNICAL_SPECIFICATION.md Normal file
View File

@@ -0,0 +1,420 @@
# 🚗 Smart Parking Finder - Technical Specification
## 📋 Project Overview
A responsive web application that helps users find and navigate to the nearest available parking lots using OpenStreetMap and Valhalla Routing Engine with real-time availability and turn-by-turn navigation.
## 🎯 Core Features
### 🔍 Location & Discovery
- GPS-based user location detection
- Interactive map with nearby parking lots
- Real-time availability display
- Distance and direction calculation
- Smart parking suggestions
### 🗺️ Navigation & Routing
- Valhalla-powered route generation
- Turn-by-turn directions
- Visual route display on map
- Estimated arrival time
- Alternative route options
### 📊 Parking Information
- Name, address, and contact details
- Real-time available slots
- Pricing per hour
- Operating hours
- Amenities and features
## 🏗️ System Architecture
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ Backend API │ │ Database │
│ (Next.js) │◄──►│ (NestJS) │◄──►│ PostgreSQL + │
│ │ │ │ │ PostGIS │
└─────────────────┘ └─────────────────┘ └─────────────────┘
┌─────────────────┐
│ Valhalla Engine │
│ (Docker) │
└─────────────────┘
```
## 🔧 Technology Stack
### Frontend
- **Framework**: Next.js 14 with TypeScript
- **Map Library**: React Leaflet + OpenStreetMap
- **UI Framework**: Tailwind CSS with custom branding
- **State Management**: React Query + Zustand
- **HTTP Client**: Axios with interceptors
- **PWA Support**: Next.js PWA plugin
### Backend
- **Framework**: NestJS with TypeScript
- **Database ORM**: TypeORM with PostGIS
- **Caching**: Redis for route caching
- **API Documentation**: Swagger/OpenAPI
- **Authentication**: JWT + Passport.js
- **Rate Limiting**: Express rate limiter
### Infrastructure
- **Routing Engine**: Valhalla (Docker)
- **Database**: PostgreSQL 15 + PostGIS 3.3
- **Deployment**: Docker Compose
- **Monitoring**: Prometheus + Grafana
- **CDN**: CloudFlare for static assets
## 📊 Database Schema
```sql
-- Parking lots table
CREATE TABLE parking_lots (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
address TEXT NOT NULL,
location GEOGRAPHY(POINT, 4326) NOT NULL,
lat DOUBLE PRECISION NOT NULL,
lng DOUBLE PRECISION NOT NULL,
hourly_rate DECIMAL(10,2),
open_time TIME,
close_time TIME,
available_slots INTEGER DEFAULT 0,
total_slots INTEGER NOT NULL,
amenities JSONB DEFAULT '{}',
contact_info JSONB DEFAULT '{}',
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- Spatial index for location queries
CREATE INDEX idx_parking_lots_location ON parking_lots USING GIST (location);
-- Users table (for favorites, history)
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE,
name VARCHAR(255),
preferences JSONB DEFAULT '{}',
created_at TIMESTAMP DEFAULT NOW()
);
-- Parking history
CREATE TABLE parking_history (
id SERIAL PRIMARY KEY,
user_id UUID REFERENCES users(id),
parking_lot_id INTEGER REFERENCES parking_lots(id),
visit_date TIMESTAMP DEFAULT NOW(),
duration_minutes INTEGER,
rating INTEGER CHECK (rating >= 1 AND rating <= 5)
);
-- Real-time parking updates
CREATE TABLE parking_updates (
id SERIAL PRIMARY KEY,
parking_lot_id INTEGER REFERENCES parking_lots(id),
available_slots INTEGER NOT NULL,
timestamp TIMESTAMP DEFAULT NOW(),
source VARCHAR(50) DEFAULT 'sensor'
);
```
## 🚀 API Endpoints
### Parking Discovery
```typescript
// GET /api/parking/nearby
interface NearbyParkingRequest {
lat: number;
lng: number;
radius?: number; // meters, default 4000
maxResults?: number; // default 20
priceRange?: [number, number];
amenities?: string[];
}
interface NearbyParkingResponse {
parkingLots: ParkingLot[];
userLocation: { lat: number; lng: number };
searchRadius: number;
}
```
### Route Planning
```typescript
// POST /api/routing/calculate
interface RouteRequest {
origin: { lat: number; lng: number };
destination: { lat: number; lng: number };
costing: 'auto' | 'bicycle' | 'pedestrian';
alternatives?: number;
}
interface RouteResponse {
routes: Route[];
summary: {
distance: number; // km
time: number; // minutes
cost: number; // estimated fuel cost
};
}
```
### Real-time Updates
```typescript
// WebSocket: /ws/parking-updates
interface ParkingUpdate {
parkingLotId: number;
availableSlots: number;
timestamp: string;
confidence: number; // 0-1
}
```
## 🎨 Brand Integration
Based on the existing assets in `/assets/`:
- **Logo**: Use Logo.png for header branding
- **Logo with Slogan**: Use Logo_and_sologan.png for splash screen
- **Location Icons**: Integrate Location.png and mini_location.png for map markers
### Color Palette
```css
:root {
--primary: #E85A4F; /* LACA Red */
--secondary: #D73502; /* Darker Red */
--accent: #8B2635; /* Deep Red */
--success: #22C55E; /* Green for available */
--warning: #F59E0B; /* Amber for limited */
--danger: #EF4444; /* Red for unavailable */
--neutral: #6B7280; /* Gray */
}
```
## 📱 UI/UX Design
### Layout Structure
```
┌─────────────────────────────────────────┐
│ Header [Logo] [Search] [Profile] │
├─────────────────┬───────────────────────┤
│ Sidebar │ Map View │
│ - Filters │ - User location │
│ - Parking List │ - Parking markers │
│ - Selected Info │ - Route overlay │
│ - Directions │ - Controls │
└─────────────────┴───────────────────────┘
```
### Responsive Breakpoints
- **Mobile**: < 768px (full-screen map with drawer)
- **Tablet**: 768px - 1024px (split view)
- **Desktop**: > 1024px (sidebar + map)
## 🐳 Docker Configuration
### Valhalla Setup
```dockerfile
# Dockerfile.valhalla
FROM ghcr.io/gis-ops/docker-valhalla/valhalla:latest
# Copy OSM data
COPY ./osm-data/*.pbf /custom_files/
# Configuration
COPY valhalla.json /valhalla.json
EXPOSE 8002
CMD ["valhalla_service", "/valhalla.json"]
```
### Docker Compose
```yaml
version: '3.8'
services:
frontend:
build: ./frontend
ports:
- "3000:3000"
environment:
- NEXT_PUBLIC_API_URL=http://backend:3001
depends_on:
- backend
backend:
build: ./backend
ports:
- "3001:3001"
environment:
- DATABASE_URL=postgresql://user:pass@postgres:5432/parking_db
- REDIS_URL=redis://redis:6379
- VALHALLA_URL=http://valhalla:8002
depends_on:
- postgres
- redis
- valhalla
postgres:
image: postgis/postgis:15-3.3
environment:
- POSTGRES_DB=parking_db
- POSTGRES_USER=user
- POSTGRES_PASSWORD=pass
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
ports:
- "6379:6379"
valhalla:
build:
context: .
dockerfile: Dockerfile.valhalla
ports:
- "8002:8002"
volumes:
- ./valhalla-data:/valhalla-data
volumes:
postgres_data:
```
## 🔐 Security Considerations
### Frontend Security
- Content Security Policy (CSP)
- HTTPS enforcement
- API key protection
- Input sanitization
### Backend Security
- Rate limiting per IP
- JWT token validation
- SQL injection prevention
- CORS configuration
### Infrastructure Security
- Database encryption at rest
- SSL/TLS certificates
- Network segmentation
- Regular security updates
## 📈 Performance Optimization
### Frontend Optimization
- Code splitting by routes
- Image optimization with Next.js
- Service worker for caching
- Lazy loading for map components
### Backend Optimization
- Database query optimization
- Redis caching for frequent requests
- Connection pooling
- Response compression
### Database Optimization
- Spatial indexes for geo queries
- Query result caching
- Read replicas for scaling
- Partitioning for large datasets
## 🚀 Deployment Strategy
### Development
```bash
# Local development setup
docker-compose -f docker-compose.dev.yml up -d
npm run dev:frontend
npm run dev:backend
```
### Production
```bash
# Production deployment
docker-compose -f docker-compose.prod.yml up -d
```
### CI/CD Pipeline
1. **Build**: Docker images for each service
2. **Test**: Unit tests, integration tests, E2E tests
3. **Deploy**: Blue-green deployment strategy
4. **Monitor**: Health checks and performance metrics
## 📊 Monitoring & Analytics
### Application Metrics
- Response times
- Error rates
- User engagement
- Route calculation performance
### Business Metrics
- Popular parking locations
- Peak usage times
- User retention
- Revenue per parking lot
## 🔄 Future Enhancements
### Phase 2 Features
- Parking reservations
- Payment integration
- User reviews and ratings
- Push notifications for parking alerts
### Phase 3 Features
- AI-powered parking predictions
- Electric vehicle charging stations
- Multi-language support
- Offline mode with cached data
## 📋 Implementation Timeline
### Week 1-2: Foundation
- Project setup and infrastructure
- Database schema and migrations
- Basic API endpoints
### Week 3-4: Core Features
- Map integration with Leaflet
- Parking lot display and search
- User location detection
### Week 5-6: Navigation
- Valhalla integration
- Route calculation and display
- Turn-by-turn directions
### Week 7-8: Polish
- UI/UX improvements
- Performance optimization
- Testing and bug fixes
### Week 9-10: Deployment
- Production setup
- CI/CD pipeline
- Monitoring and analytics
## 🏁 Success Metrics
### Technical KPIs
- Page load time < 2 seconds
- Route calculation < 3 seconds
- 99.9% uptime
- Zero security vulnerabilities
### User Experience KPIs
- User retention > 60%
- Average session time > 5 minutes
- Route accuracy > 95%
- User satisfaction score > 4.5/5
This comprehensive specification provides a solid foundation for building a world-class parking finder application with modern web technologies and best practices.

BIN
assets/Location.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
assets/Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
assets/Logo_and_sologan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
assets/mini_location.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

37
backend/.env Normal file
View File

@@ -0,0 +1,37 @@
# Environment Configuration
NODE_ENV=development
PORT=3001
# Database Configuration
DATABASE_URL=postgresql://parking_user:parking_pass@localhost:5432/parking_db
# Redis Configuration
REDIS_URL=redis://localhost:6379
# Valhalla Routing Engine
VALHALLA_URL=http://localhost:8002
# CORS Configuration
CORS_ORIGIN=http://localhost:3000
# Security
JWT_SECRET=your-super-secure-jwt-secret-256-bit-change-in-production
JWT_EXPIRATION=1h
# Logging
LOG_LEVEL=debug
# API Configuration
API_RATE_LIMIT=100
API_TIMEOUT=30000
# Cache Configuration
REDIS_CACHE_TTL=300
ROUTE_CACHE_TTL=300
# External APIs (if needed)
MAP_TILES_URL=https://tile.openstreetmap.org/{z}/{x}/{y}.png
# Development only
DEBUG=true
HOT_RELOAD=true

47
backend/Dockerfile Normal file
View File

@@ -0,0 +1,47 @@
# Multi-stage build for production optimization
FROM node:18-alpine as builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY tsconfig*.json ./
# Install dependencies
RUN npm ci --only=production && npm cache clean --force
# Copy source code
COPY src/ ./src/
# Build the application
RUN npm run build
# Production stage
FROM node:18-alpine as production
WORKDIR /app
# Install only production dependencies
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nestjs -u 1001
# Change ownership of the working directory
RUN chown -R nestjs:nodejs /app
USER nestjs
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node dist/health-check.js || exit 1
# Start the application
CMD ["node", "dist/main"]

418
backend/README.md Normal file
View File

@@ -0,0 +1,418 @@
# 🚗 Smart Parking Finder - Backend API
A robust NestJS backend API for the Smart Parking Finder application, providing parking discovery, route calculation, and real-time availability updates.
## 🚀 Features
- **Parking Discovery**: Find nearby parking lots using PostGIS spatial queries
- **Route Calculation**: Integration with Valhalla routing engine for turn-by-turn directions
- **Real-time Updates**: WebSocket support for live parking availability
- **Comprehensive API**: RESTful endpoints with OpenAPI/Swagger documentation
- **Performance Optimized**: Redis caching and database connection pooling
- **Production Ready**: Docker containerization with health checks
## 🛠️ Technology Stack
- **Framework**: NestJS with TypeScript
- **Database**: PostgreSQL 15 + PostGIS 3.3
- **ORM**: TypeORM with spatial support
- **Caching**: Redis for performance optimization
- **Documentation**: Swagger/OpenAPI
- **Security**: Helmet, CORS, rate limiting
- **Validation**: Class-validator and class-transformer
## 📋 Prerequisites
- Node.js 18+ and npm
- Docker and Docker Compose
- PostgreSQL with PostGIS extension
- Redis server
## 🔧 Installation
### Using Docker (Recommended)
```bash
# Start the entire stack
docker-compose up -d
# View logs
docker-compose logs -f backend
```
### Manual Setup
```bash
# 1. Install dependencies
npm install
# 2. Set up environment variables
cp .env.example .env
# 3. Start PostgreSQL and Redis
# Make sure both services are running
# 4. Run database migrations
npm run migration:run
# 5. Seed initial data
npm run seed
# 6. Start development server
npm run start:dev
```
## 🌍 Environment Variables
```bash
# Application
NODE_ENV=development
PORT=3001
CORS_ORIGIN=http://localhost:3000
# Database
DATABASE_URL=postgresql://parking_user:parking_pass@localhost:5432/parking_db
# Redis
REDIS_URL=redis://localhost:6379
# External Services
VALHALLA_URL=http://valhalla:8002
# Security
JWT_SECRET=your-super-secure-jwt-secret
# Logging
LOG_LEVEL=debug
```
## 📚 API Documentation
Once the server is running, access the interactive API documentation:
- **Swagger UI**: http://localhost:3001/api/docs
- **OpenAPI JSON**: http://localhost:3001/api/docs-json
## 🔗 API Endpoints
### Parking Management
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/parking/nearby` | Find nearby parking lots |
| GET | `/api/parking` | Get all parking lots |
| GET | `/api/parking/popular` | Get popular parking lots |
| GET | `/api/parking/:id` | Get parking lot details |
| PUT | `/api/parking/:id/availability` | Update availability |
| GET | `/api/parking/:id/history` | Get update history |
### Route Calculation
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/routing/calculate` | Calculate route between points |
| GET | `/api/routing/status` | Check routing service status |
### System Health
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/health` | Application health check |
## 🧪 Example API Usage
### Find Nearby Parking
```bash
curl -X POST http://localhost:3001/api/parking/nearby \
-H "Content-Type: application/json" \
-d '{
"lat": 1.3521,
"lng": 103.8198,
"radius": 4000,
"maxResults": 10
}'
```
### Calculate Route
```bash
curl -X POST http://localhost:3001/api/routing/calculate \
-H "Content-Type: application/json" \
-d '{
"originLat": 1.3521,
"originLng": 103.8198,
"destinationLat": 1.3048,
"destinationLng": 103.8318,
"costing": "auto"
}'
```
### Update Parking Availability
```bash
curl -X PUT http://localhost:3001/api/parking/1/availability \
-H "Content-Type: application/json" \
-d '{
"availableSlots": 45,
"source": "sensor",
"confidence": 0.95
}'
```
## 🗄️ Database Schema
### Parking Lots Table
```sql
CREATE TABLE parking_lots (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
address TEXT NOT NULL,
location GEOGRAPHY(POINT, 4326) NOT NULL,
lat DOUBLE PRECISION NOT NULL,
lng DOUBLE PRECISION NOT NULL,
hourly_rate DECIMAL(10,2),
open_time TIME,
close_time TIME,
available_slots INTEGER DEFAULT 0,
total_slots INTEGER NOT NULL,
amenities JSONB DEFAULT '{}',
contact_info JSONB DEFAULT '{}',
is_active BOOLEAN DEFAULT true,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- Spatial index for efficient location queries
CREATE INDEX idx_parking_lots_location ON parking_lots USING GIST (location);
```
## 🔧 Database Management
### Run Migrations
```bash
# Generate new migration
npm run migration:generate src/database/migrations/AddNewFeature
# Run pending migrations
npm run migration:run
# Revert last migration
npm run migration:revert
```
### Seed Data
```bash
# Run all seeds
npm run seed
# Seed specific data
npm run seed:parking-lots
```
## 📈 Performance Features
### Spatial Queries
Optimized PostGIS queries for efficient nearby parking search:
```sql
-- Find parking within 4km radius
SELECT *, ST_Distance(location::geography, ST_Point($1, $2)::geography) as distance
FROM parking_lots
WHERE ST_DWithin(location::geography, ST_Point($1, $2)::geography, 4000)
ORDER BY distance ASC;
```
### Caching Strategy
- **Route Calculations**: Cached for 5 minutes
- **Parking Data**: Cached for 1 minute
- **Static Data**: Cached for 1 hour
### Connection Pooling
```typescript
// Database configuration
extra: {
max: 20, // Maximum connections
connectionTimeoutMillis: 2000,
idleTimeoutMillis: 30000,
}
```
## 🛡️ Security Features
- **Rate Limiting**: 100 requests per minute per IP
- **Input Validation**: Comprehensive DTO validation
- **SQL Injection Protection**: TypeORM query builder
- **CORS Configuration**: Configurable origins
- **Helmet**: Security headers middleware
## 📊 Monitoring & Logging
### Health Checks
```bash
# Application health
curl http://localhost:3001/api/health
# Database connectivity
curl http://localhost:3001/api/health/database
# External services
curl http://localhost:3001/api/routing/status
```
### Logging Levels
- **Error**: Application errors and exceptions
- **Warn**: Performance issues and deprecation warnings
- **Info**: General application flow
- **Debug**: Detailed execution information
## 🧪 Testing
```bash
# Unit tests
npm run test
# Test coverage
npm run test:cov
# End-to-end tests
npm run test:e2e
# Watch mode
npm run test:watch
```
## 🐳 Docker Configuration
### Development
```bash
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f backend
# Execute commands in container
docker-compose exec backend npm run migration:run
```
### Production
```bash
# Build production image
docker build -t smart-parking-backend .
# Run production container
docker run -p 3001:3001 smart-parking-backend
```
## 🔍 Troubleshooting
### Common Issues
1. **Database Connection Failed**
```bash
# Check PostgreSQL status
docker-compose exec postgres pg_isready -U parking_user
# View database logs
docker-compose logs postgres
```
2. **Valhalla Service Unavailable**
```bash
# Check Valhalla status
curl http://localhost:8002/status
# Restart Valhalla service
docker-compose restart valhalla
```
3. **High Memory Usage**
```bash
# Monitor Docker stats
docker stats
# Optimize connection pool
# Reduce max connections in database config
```
### Performance Optimization
1. **Database Indexes**
```sql
-- Monitor slow queries
SELECT query, mean_time, calls
FROM pg_stat_statements
ORDER BY mean_time DESC;
-- Add indexes for frequent queries
CREATE INDEX idx_parking_lots_hourly_rate ON parking_lots(hourly_rate);
```
2. **Cache Optimization**
```bash
# Monitor Redis memory usage
docker-compose exec redis redis-cli info memory
# Clear cache if needed
docker-compose exec redis redis-cli FLUSHALL
```
## 📝 Development Guidelines
### Code Style
- Use TypeScript strict mode
- Follow NestJS conventions
- Implement proper error handling
- Add comprehensive API documentation
- Write unit tests for services
- Use proper logging levels
### Git Workflow
```bash
# Feature branch naming
git checkout -b feature/parking-search-optimization
# Commit message format
git commit -m "feat(parking): optimize spatial queries with better indexing"
# Push and create PR
git push origin feature/parking-search-optimization
```
## 🚀 Deployment
### Production Checklist
- [ ] Environment variables configured
- [ ] Database migrations applied
- [ ] SSL certificates installed
- [ ] Monitoring setup
- [ ] Backup strategy implemented
- [ ] Load balancer configured
- [ ] CDN setup for static assets
## 📞 Support
For technical issues or questions:
- **Documentation**: Check the API docs at `/api/docs`
- **Logs**: Use `docker-compose logs backend`
- **Health Check**: Monitor `/api/health` endpoint
- **Performance**: Check database and Redis metrics
---
Built with ❤️ using NestJS and TypeScript

2
backend/dist/app.module.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare class AppModule {
}

47
backend/dist/app.module.js vendored Normal file
View File

@@ -0,0 +1,47 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppModule = void 0;
const common_1 = require("@nestjs/common");
const config_1 = require("@nestjs/config");
const typeorm_1 = require("@nestjs/typeorm");
const throttler_1 = require("@nestjs/throttler");
const database_config_1 = require("./config/database.config");
const parking_module_1 = require("./modules/parking/parking.module");
const routing_module_1 = require("./modules/routing/routing.module");
const users_module_1 = require("./modules/users/users.module");
const auth_module_1 = require("./modules/auth/auth.module");
const health_module_1 = require("./modules/health/health.module");
let AppModule = class AppModule {
};
exports.AppModule = AppModule;
exports.AppModule = AppModule = __decorate([
(0, common_1.Module)({
imports: [
config_1.ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
}),
typeorm_1.TypeOrmModule.forRootAsync({
imports: [config_1.ConfigModule],
useClass: database_config_1.DatabaseConfig,
inject: [config_1.ConfigService],
}),
throttler_1.ThrottlerModule.forRoot({
ttl: 60000,
limit: 100,
}),
parking_module_1.ParkingModule,
routing_module_1.RoutingModule,
users_module_1.UsersModule,
auth_module_1.AuthModule,
health_module_1.HealthModule,
],
})
], AppModule);
//# sourceMappingURL=app.module.js.map

1
backend/dist/app.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAA6D;AAC7D,6CAAgD;AAChD,iDAAoD;AACpD,8DAA0D;AAC1D,qEAAiE;AACjE,qEAAiE;AACjE,+DAA2D;AAC3D,4DAAwD;AACxD,kEAA8D;AAwBvD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAtBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,MAAM;aACpB,CAAC;YACF,uBAAa,CAAC,YAAY,CAAC;gBACzB,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,QAAQ,EAAE,gCAAc;gBACxB,MAAM,EAAE,CAAC,sBAAa,CAAC;aACxB,CAAC;YACF,2BAAe,CAAC,OAAO,CAAC;gBACtB,GAAG,EAAE,KAAK;gBACV,KAAK,EAAE,GAAG;aACX,CAAC;YACF,8BAAa;YACb,8BAAa;YACb,0BAAW;YACX,wBAAU;YACV,4BAAY;SACb;KACF,CAAC;GACW,SAAS,CAAG"}

View File

@@ -0,0 +1,7 @@
import { ConfigService } from '@nestjs/config';
import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm';
export declare class DatabaseConfig implements TypeOrmOptionsFactory {
private configService;
constructor(configService: ConfigService);
createTypeOrmOptions(): TypeOrmModuleOptions;
}

48
backend/dist/config/database.config.js vendored Normal file
View File

@@ -0,0 +1,48 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatabaseConfig = void 0;
const common_1 = require("@nestjs/common");
const config_1 = require("@nestjs/config");
const parking_lot_entity_1 = require("../modules/parking/entities/parking-lot.entity");
const user_entity_1 = require("../modules/users/entities/user.entity");
const parking_history_entity_1 = require("../modules/parking/entities/parking-history.entity");
const parking_update_entity_1 = require("../modules/parking/entities/parking-update.entity");
let DatabaseConfig = class DatabaseConfig {
constructor(configService) {
this.configService = configService;
}
createTypeOrmOptions() {
return {
type: 'postgres',
url: this.configService.get('DATABASE_URL') ||
'postgresql://parking_user:parking_pass@localhost:5432/parking_db',
entities: [parking_lot_entity_1.ParkingLot, user_entity_1.User, parking_history_entity_1.ParkingHistory, parking_update_entity_1.ParkingUpdate],
migrations: ['dist/database/migrations/*.js'],
synchronize: this.configService.get('NODE_ENV') === 'development',
logging: this.configService.get('NODE_ENV') === 'development',
ssl: this.configService.get('NODE_ENV') === 'production' ? {
rejectUnauthorized: false,
} : false,
extra: {
max: 20,
connectionTimeoutMillis: 2000,
idleTimeoutMillis: 30000,
},
};
}
};
exports.DatabaseConfig = DatabaseConfig;
exports.DatabaseConfig = DatabaseConfig = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [config_1.ConfigService])
], DatabaseConfig);
//# sourceMappingURL=database.config.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"database.config.js","sourceRoot":"","sources":["../../src/config/database.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAE/C,uFAA4E;AAC5E,uEAA6D;AAC7D,+FAAoF;AACpF,6FAAkF;AAG3E,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAEpD,oBAAoB;QAClB,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,cAAc,CAAC;gBAC9C,kEAAkE;YACvE,QAAQ,EAAE,CAAC,+BAAU,EAAE,kBAAI,EAAE,uCAAc,EAAE,qCAAa,CAAC;YAC3D,UAAU,EAAE,CAAC,+BAA+B,CAAC;YAC7C,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,KAAK,aAAa;YACzE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,KAAK,aAAa;YACrE,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC;gBACjE,kBAAkB,EAAE,KAAK;aAC1B,CAAC,CAAC,CAAC,KAAK;YACT,KAAK,EAAE;gBACL,GAAG,EAAE,EAAE;gBACP,uBAAuB,EAAE,IAAI;gBAC7B,iBAAiB,EAAE,KAAK;aACzB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAtBY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAEwB,sBAAa;GADrC,cAAc,CAsB1B"}

View File

@@ -0,0 +1,2 @@
import { DataSource } from 'typeorm';
export declare function seedParkingLots(dataSource: DataSource): Promise<void>;

View File

@@ -0,0 +1,254 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.seedParkingLots = seedParkingLots;
const parking_lot_entity_1 = require("../../modules/parking/entities/parking-lot.entity");
async function seedParkingLots(dataSource) {
const parkingRepository = dataSource.getRepository(parking_lot_entity_1.ParkingLot);
const parkingLots = [
{
name: 'Central Mall Parking',
address: '123 Orchard Road, Singapore 238872',
lat: 1.3048,
lng: 103.8318,
location: `POINT(103.8318 1.3048)`,
hourlyRate: 5.00,
openTime: '06:00',
closeTime: '24:00',
availableSlots: 45,
totalSlots: 200,
amenities: {
covered: true,
security: true,
ev_charging: true,
wheelchair_accessible: true,
valet_service: false,
},
contactInfo: {
phone: '+65 6123 4567',
email: 'parking@centralmall.sg',
website: 'https://centralmall.sg/parking',
},
},
{
name: 'Marina Bay Business District Parking',
address: '8 Marina Boulevard, Singapore 018981',
lat: 1.2802,
lng: 103.8537,
location: `POINT(103.8537 1.2802)`,
hourlyRate: 8.50,
openTime: '00:00',
closeTime: '23:59',
availableSlots: 12,
totalSlots: 150,
amenities: {
covered: true,
security: true,
ev_charging: true,
wheelchair_accessible: true,
valet_service: true,
},
contactInfo: {
phone: '+65 6234 5678',
email: 'parking@marinabay.sg',
},
},
{
name: 'Chinatown Heritage Parking',
address: '48 Pagoda Street, Singapore 059207',
lat: 1.2838,
lng: 103.8444,
location: `POINT(103.8444 1.2838)`,
hourlyRate: 3.50,
openTime: '07:00',
closeTime: '22:00',
availableSlots: 8,
totalSlots: 80,
amenities: {
covered: false,
security: true,
ev_charging: false,
wheelchair_accessible: true,
valet_service: false,
},
contactInfo: {
phone: '+65 6345 6789',
},
},
{
name: 'Sentosa Island Resort Parking',
address: '39 Artillery Avenue, Singapore 099958',
lat: 1.2494,
lng: 103.8303,
location: `POINT(103.8303 1.2494)`,
hourlyRate: 6.00,
openTime: '06:00',
closeTime: '02:00',
availableSlots: 78,
totalSlots: 300,
amenities: {
covered: true,
security: true,
ev_charging: true,
wheelchair_accessible: true,
valet_service: true,
},
contactInfo: {
phone: '+65 6456 7890',
email: 'parking@sentosa.sg',
website: 'https://sentosa.sg/parking',
},
},
{
name: 'Clarke Quay Entertainment Parking',
address: '3E River Valley Road, Singapore 179024',
lat: 1.2897,
lng: 103.8467,
location: `POINT(103.8467 1.2897)`,
hourlyRate: 7.00,
openTime: '10:00',
closeTime: '04:00',
availableSlots: 23,
totalSlots: 120,
amenities: {
covered: true,
security: true,
ev_charging: false,
wheelchair_accessible: true,
valet_service: false,
},
contactInfo: {
phone: '+65 6567 8901',
email: 'parking@clarkequay.sg',
},
},
{
name: 'Little India Cultural Parking',
address: '48 Serangoon Road, Singapore 217959',
lat: 1.3093,
lng: 103.8522,
location: `POINT(103.8522 1.3093)`,
hourlyRate: 4.00,
openTime: '05:00',
closeTime: '23:00',
availableSlots: 34,
totalSlots: 100,
amenities: {
covered: false,
security: true,
ev_charging: false,
wheelchair_accessible: false,
valet_service: false,
},
contactInfo: {
phone: '+65 6678 9012',
},
},
{
name: 'Changi Airport Terminal Parking',
address: 'Airport Boulevard, Singapore 819663',
lat: 1.3644,
lng: 103.9915,
location: `POINT(103.9915 1.3644)`,
hourlyRate: 4.50,
openTime: '00:00',
closeTime: '23:59',
availableSlots: 156,
totalSlots: 800,
amenities: {
covered: true,
security: true,
ev_charging: true,
wheelchair_accessible: true,
valet_service: true,
},
contactInfo: {
phone: '+65 6789 0123',
email: 'parking@changiairport.sg',
website: 'https://changiairport.com/parking',
},
},
{
name: 'Bugis Street Shopping Parking',
address: '3 New Bugis Street, Singapore 188867',
lat: 1.3006,
lng: 103.8558,
location: `POINT(103.8558 1.3006)`,
hourlyRate: 5.50,
openTime: '08:00',
closeTime: '23:00',
availableSlots: 67,
totalSlots: 180,
amenities: {
covered: true,
security: true,
ev_charging: false,
wheelchair_accessible: true,
valet_service: false,
},
contactInfo: {
phone: '+65 6890 1234',
email: 'parking@bugisstreet.sg',
},
},
{
name: 'Jurong East Hub Parking',
address: '1 Jurong West Central 2, Singapore 648886',
lat: 1.3329,
lng: 103.7436,
location: `POINT(103.7436 1.3329)`,
hourlyRate: 3.00,
openTime: '06:00',
closeTime: '24:00',
availableSlots: 89,
totalSlots: 250,
amenities: {
covered: true,
security: true,
ev_charging: true,
wheelchair_accessible: true,
valet_service: false,
},
contactInfo: {
phone: '+65 6901 2345',
email: 'parking@jurongeast.sg',
},
},
{
name: 'East Coast Park Recreation Parking',
address: 'East Coast Park Service Road, Singapore 449876',
lat: 1.3018,
lng: 103.9057,
location: `POINT(103.9057 1.3018)`,
hourlyRate: 2.50,
openTime: '05:00',
closeTime: '02:00',
availableSlots: 145,
totalSlots: 400,
amenities: {
covered: false,
security: false,
ev_charging: false,
wheelchair_accessible: true,
valet_service: false,
},
contactInfo: {
phone: '+65 6012 3456',
},
},
];
for (const lotData of parkingLots) {
const existingLot = await parkingRepository.findOne({
where: { name: lotData.name },
});
if (!existingLot) {
const lot = parkingRepository.create(lotData);
await parkingRepository.save(lot);
console.log(`Created parking lot: ${lotData.name}`);
}
else {
console.log(`Parking lot already exists: ${lotData.name}`);
}
}
console.log('Parking lots seeding completed');
}
//# sourceMappingURL=parking-lots.seed.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parking-lots.seed.js","sourceRoot":"","sources":["../../../src/database/seeds/parking-lots.seed.ts"],"names":[],"mappings":";;AAGA,0CA2PC;AA7PD,0FAA+E;AAExE,KAAK,UAAU,eAAe,CAAC,UAAsB;IAC1D,MAAM,iBA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F,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC;YAClD,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;SAC9B,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,GAAG,GAAG,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,CAAC,GAAG,CAAC,wBAAwB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,+BAA+B,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC"}

1
backend/dist/main.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

37
backend/dist/main.js vendored Normal file
View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@nestjs/core");
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const app_module_1 = require("./app.module");
const compression = require("compression");
const helmet = require("helmet");
async function bootstrap() {
const app = await core_1.NestFactory.create(app_module_1.AppModule);
app.use(helmet.default());
app.use(compression());
app.enableCors({
origin: process.env.CORS_ORIGIN || 'http://localhost:3000',
credentials: true,
});
app.useGlobalPipes(new common_1.ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
}));
app.setGlobalPrefix('api');
const config = new swagger_1.DocumentBuilder()
.setTitle('Smart Parking Finder API')
.setDescription('API for finding and navigating to parking lots')
.setVersion('1.0')
.addBearerAuth()
.build();
const document = swagger_1.SwaggerModule.createDocument(app, config);
swagger_1.SwaggerModule.setup('api/docs', app, document);
const port = process.env.PORT || 3001;
await app.listen(port);
console.log(`🚀 Application is running on: http://localhost:${port}`);
console.log(`📚 API Documentation: http://localhost:${port}/api/docs`);
}
bootstrap();
//# sourceMappingURL=main.js.map

1
backend/dist/main.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAiE;AACjE,6CAAyC;AACzC,2CAA2C;AAC3C,iCAAiC;AAEjC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAGhD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1B,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IAGvB,GAAG,CAAC,UAAU,CAAC;QACb,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,uBAAuB;QAC1D,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAGH,GAAG,CAAC,cAAc,CAChB,IAAI,uBAAc,CAAC;QACjB,SAAS,EAAE,IAAI;QACf,oBAAoB,EAAE,IAAI;QAC1B,SAAS,EAAE,IAAI;KAChB,CAAC,CACH,CAAC;IAGF,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAG3B,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE;SACjC,QAAQ,CAAC,0BAA0B,CAAC;SACpC,cAAc,CAAC,gDAAgD,CAAC;SAChE,UAAU,CAAC,KAAK,CAAC;SACjB,aAAa,EAAE;SACf,KAAK,EAAE,CAAC;IAEX,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,uBAAa,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;IACtC,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEvB,OAAO,CAAC,GAAG,CAAC,kDAAkD,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,0CAA0C,IAAI,WAAW,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,EAAE,CAAC"}

View File

@@ -0,0 +1,12 @@
import { AuthService } from './auth.service';
export declare class AuthController {
private authService;
constructor(authService: AuthService);
login(loginDto: {
email: string;
password: string;
}): Promise<{
access_token: string;
user: any;
}>;
}

View File

@@ -0,0 +1,41 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const auth_service_1 = require("./auth.service");
let AuthController = class AuthController {
constructor(authService) {
this.authService = authService;
}
async login(loginDto) {
return this.authService.login(loginDto);
}
};
exports.AuthController = AuthController;
__decorate([
(0, common_1.Post)('login'),
(0, swagger_1.ApiOperation)({ summary: 'User login' }),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "login", null);
exports.AuthController = AuthController = __decorate([
(0, swagger_1.ApiTags)('Authentication'),
(0, common_1.Controller)('auth'),
__metadata("design:paramtypes", [auth_service_1.AuthService])
], AuthController);
//# sourceMappingURL=auth.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwD;AACxD,6CAAwD;AACxD,iDAA6C;AAItC,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAI1C,AAAN,KAAK,CAAC,KAAK,CAAS,QAA6C;QAC/D,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AARY,wCAAc;AAKnB;IAFL,IAAA,aAAI,EAAC,OAAO,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAC3B,WAAA,IAAA,aAAI,GAAE,CAAA;;;;2CAElB;yBAPU,cAAc;IAF1B,IAAA,iBAAO,EAAC,gBAAgB,CAAC;IACzB,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAEgB,0BAAW;GADjC,cAAc,CAQ1B"}

View File

@@ -0,0 +1,2 @@
export declare class AuthModule {
}

View File

@@ -0,0 +1,23 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthModule = void 0;
const common_1 = require("@nestjs/common");
const auth_controller_1 = require("./auth.controller");
const auth_service_1 = require("./auth.service");
let AuthModule = class AuthModule {
};
exports.AuthModule = AuthModule;
exports.AuthModule = AuthModule = __decorate([
(0, common_1.Module)({
controllers: [auth_controller_1.AuthController],
providers: [auth_service_1.AuthService],
exports: [auth_service_1.AuthService],
})
], AuthModule);
//# sourceMappingURL=auth.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uDAAmD;AACnD,iDAA6C;AAOtC,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IALtB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,SAAS,EAAE,CAAC,0BAAW,CAAC;QACxB,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAG"}

View File

@@ -0,0 +1,7 @@
export declare class AuthService {
validateUser(email: string, password: string): Promise<any>;
login(user: any): Promise<{
access_token: string;
user: any;
}>;
}

View File

@@ -0,0 +1,26 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthService = void 0;
const common_1 = require("@nestjs/common");
let AuthService = class AuthService {
async validateUser(email, password) {
return null;
}
async login(user) {
return {
access_token: 'placeholder_token',
user,
};
}
};
exports.AuthService = AuthService;
exports.AuthService = AuthService = __decorate([
(0, common_1.Injectable)()
], AuthService);
//# sourceMappingURL=auth.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../../src/modules/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,QAAgB;QAEhD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAS;QAEnB,OAAO;YACL,YAAY,EAAE,mBAAmB;YACjC,IAAI;SACL,CAAC;IACJ,CAAC;CACF,CAAA;AAbY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;GACA,WAAW,CAavB"}

View File

@@ -0,0 +1,11 @@
import { HealthService } from './health.service';
export declare class HealthController {
private readonly healthService;
constructor(healthService: HealthService);
getHealth(): {
status: string;
timestamp: string;
uptime: number;
environment: string;
};
}

View File

@@ -0,0 +1,37 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HealthController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const health_service_1 = require("./health.service");
let HealthController = class HealthController {
constructor(healthService) {
this.healthService = healthService;
}
getHealth() {
return this.healthService.getHealth();
}
};
exports.HealthController = HealthController;
__decorate([
(0, common_1.Get)(),
(0, swagger_1.ApiOperation)({ summary: 'Health check endpoint' }),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], HealthController.prototype, "getHealth", null);
exports.HealthController = HealthController = __decorate([
(0, swagger_1.ApiTags)('Health'),
(0, common_1.Controller)('health'),
__metadata("design:paramtypes", [health_service_1.HealthService])
], HealthController);
//# sourceMappingURL=health.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../../src/modules/health/health.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,6CAAwD;AACxD,qDAAiD;AAI1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAI7D,SAAS;QACP,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;IACxC,CAAC;CACF,CAAA;AARY,4CAAgB;AAK3B;IAFC,IAAA,YAAG,GAAE;IACL,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;;;;iDAGlD;2BAPU,gBAAgB;IAF5B,IAAA,iBAAO,EAAC,QAAQ,CAAC;IACjB,IAAA,mBAAU,EAAC,QAAQ,CAAC;qCAEyB,8BAAa;GAD9C,gBAAgB,CAQ5B"}

View File

@@ -0,0 +1,2 @@
export declare class HealthModule {
}

View File

@@ -0,0 +1,22 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HealthModule = void 0;
const common_1 = require("@nestjs/common");
const health_controller_1 = require("./health.controller");
const health_service_1 = require("./health.service");
let HealthModule = class HealthModule {
};
exports.HealthModule = HealthModule;
exports.HealthModule = HealthModule = __decorate([
(0, common_1.Module)({
controllers: [health_controller_1.HealthController],
providers: [health_service_1.HealthService],
})
], HealthModule);
//# sourceMappingURL=health.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"health.module.js","sourceRoot":"","sources":["../../../src/modules/health/health.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AACvD,qDAAiD;AAM1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IAJxB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,CAAC;KAC3B,CAAC;GACW,YAAY,CAAG"}

View File

@@ -0,0 +1,8 @@
export declare class HealthService {
getHealth(): {
status: string;
timestamp: string;
uptime: number;
environment: string;
};
}

View File

@@ -0,0 +1,25 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HealthService = void 0;
const common_1 = require("@nestjs/common");
let HealthService = class HealthService {
getHealth() {
return {
status: 'ok',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
environment: process.env.NODE_ENV || 'development',
};
}
};
exports.HealthService = HealthService;
exports.HealthService = HealthService = __decorate([
(0, common_1.Injectable)()
], HealthService);
//# sourceMappingURL=health.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"health.service.js","sourceRoot":"","sources":["../../../src/modules/health/health.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,SAAS;QACP,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;YACxB,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa;SACnD,CAAC;IACJ,CAAC;CACF,CAAA;AATY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CASzB"}

View File

@@ -0,0 +1,9 @@
export declare class FindNearbyParkingDto {
lat: number;
lng: number;
radius?: number;
maxResults?: number;
priceRange?: [number, number];
amenities?: string[];
availabilityFilter?: 'available' | 'limited' | 'full';
}

View File

@@ -0,0 +1,112 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FindNearbyParkingDto = void 0;
const swagger_1 = require("@nestjs/swagger");
const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
class FindNearbyParkingDto {
constructor() {
this.radius = 4000;
this.maxResults = 20;
}
}
exports.FindNearbyParkingDto = FindNearbyParkingDto;
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Latitude coordinate',
example: 1.3521,
minimum: -90,
maximum: 90
}),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(-90),
(0, class_validator_1.Max)(90),
(0, class_transformer_1.Transform)(({ value }) => parseFloat(value)),
__metadata("design:type", Number)
], FindNearbyParkingDto.prototype, "lat", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Longitude coordinate',
example: 103.8198,
minimum: -180,
maximum: 180
}),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(-180),
(0, class_validator_1.Max)(180),
(0, class_transformer_1.Transform)(({ value }) => parseFloat(value)),
__metadata("design:type", Number)
], FindNearbyParkingDto.prototype, "lng", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Search radius in meters',
example: 4000,
minimum: 100,
maximum: 10000,
required: false
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(100),
(0, class_validator_1.Max)(10000),
(0, class_transformer_1.Transform)(({ value }) => parseFloat(value)),
__metadata("design:type", Number)
], FindNearbyParkingDto.prototype, "radius", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Maximum number of results to return',
example: 20,
minimum: 1,
maximum: 100,
required: false
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Max)(100),
(0, class_transformer_1.Transform)(({ value }) => parseInt(value)),
__metadata("design:type", Number)
], FindNearbyParkingDto.prototype, "maxResults", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Price range filter [min, max] per hour',
example: [0, 10],
required: false,
type: [Number]
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsArray)(),
(0, class_validator_1.IsNumber)({}, { each: true }),
__metadata("design:type", Array)
], FindNearbyParkingDto.prototype, "priceRange", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Required amenities',
example: ['covered', 'security', 'ev_charging'],
required: false,
type: [String]
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsArray)(),
__metadata("design:type", Array)
], FindNearbyParkingDto.prototype, "amenities", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Filter by availability status',
example: 'available',
enum: ['available', 'limited', 'full'],
required: false
}),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], FindNearbyParkingDto.prototype, "availabilityFilter", void 0);
//# sourceMappingURL=find-nearby-parking.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"find-nearby-parking.dto.js","sourceRoot":"","sources":["../../../../src/modules/parking/dto/find-nearby-parking.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAA0E;AAC1E,yDAA8C;AAE9C,MAAa,oBAAoB;IAAjC;QAqCE,WAAM,GAAY,IAAI,CAAC;QAcvB,eAAU,GAAY,EAAE,CAAC;IA+B3B,CAAC;CAAA;AAlFD,oDAkFC;AAvEC;IAVC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,qBAAqB;QAClC,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,CAAC,EAAE;QACZ,OAAO,EAAE,EAAE;KACZ,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,EAAE,CAAC;IACR,IAAA,qBAAG,EAAC,EAAE,CAAC;IACP,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;;iDAChC;AAYZ;IAVC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,CAAC,GAAG;QACb,OAAO,EAAE,GAAG;KACb,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,GAAG,CA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ACC;AAU9B;IARC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC;QAC/C,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,CAAC,MAAM,CAAC;KACf,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;;uDACW;AASrB;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,+BAA+B;QAC5C,OAAO,EAAE,WAAW;QACpB,IAAI,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC;QACtC,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;;gEACyC"}

View File

@@ -0,0 +1,6 @@
export declare class UpdateParkingAvailabilityDto {
availableSlots: number;
source?: string;
confidence?: number;
metadata?: Record<string, any>;
}

View File

@@ -0,0 +1,65 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateParkingAvailabilityDto = void 0;
const swagger_1 = require("@nestjs/swagger");
const class_validator_1 = require("class-validator");
class UpdateParkingAvailabilityDto {
constructor() {
this.source = 'manual';
this.confidence = 1.0;
}
}
exports.UpdateParkingAvailabilityDto = UpdateParkingAvailabilityDto;
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Number of available parking slots',
example: 15,
minimum: 0
}),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
__metadata("design:type", Number)
], UpdateParkingAvailabilityDto.prototype, "availableSlots", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Source of the update',
example: 'sensor',
required: false
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateParkingAvailabilityDto.prototype, "source", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Confidence level of the update (0-1)',
example: 0.95,
minimum: 0,
maximum: 1,
required: false
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
(0, class_validator_1.Max)(1),
__metadata("design:type", Number)
], UpdateParkingAvailabilityDto.prototype, "confidence", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Additional metadata',
example: { sensor_id: 'PARK_001', battery_level: 85 },
required: false
}),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Object)
], UpdateParkingAvailabilityDto.prototype, "metadata", void 0);
//# sourceMappingURL=update-availability.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"update-availability.dto.js","sourceRoot":"","sources":["../../../../src/modules/parking/dto/update-availability.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAA2E;AAE3E,MAAa,4BAA4B;IAAzC;QAiBE,WAAM,GAAY,QAAQ,CAAC;QAa3B,eAAU,GAAY,GAAG,CAAC;IAS5B,CAAC;CAAA;AAvCD,oEAuCC;AA/BC;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC;KACX,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;;oEACgB;AASvB;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,QAAQ;QACjB,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;4DACgB;AAa3B;IAXC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,sCAAsC;QACnD,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,qBAAG,EAAC,CAAC,CAAC;;gEACmB;AAQ1B;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,qBAAqB;QAClC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,EAAE;QACrD,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;;8DACkB"}

View File

@@ -0,0 +1,13 @@
import { User } from '../../users/entities/user.entity';
import { ParkingLot } from './parking-lot.entity';
export declare class ParkingHistory {
id: number;
userId: string;
parkingLotId: number;
visitDate: Date;
durationMinutes: number;
rating: number;
review: string;
user: User;
parkingLot: ParkingLot;
}

View File

@@ -0,0 +1,68 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParkingHistory = void 0;
const typeorm_1 = require("typeorm");
const swagger_1 = require("@nestjs/swagger");
const user_entity_1 = require("../../users/entities/user.entity");
const parking_lot_entity_1 = require("./parking-lot.entity");
let ParkingHistory = class ParkingHistory {
};
exports.ParkingHistory = ParkingHistory;
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Unique identifier for the parking history entry' }),
(0, typeorm_1.PrimaryGeneratedColumn)(),
__metadata("design:type", Number)
], ParkingHistory.prototype, "id", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'User who visited the parking lot' }),
(0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ParkingHistory.prototype, "userId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Parking lot that was visited' }),
(0, typeorm_1.Column)({ type: 'int' }),
__metadata("design:type", Number)
], ParkingHistory.prototype, "parkingLotId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Date and time of the visit' }),
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], ParkingHistory.prototype, "visitDate", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Duration of parking in minutes' }),
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
__metadata("design:type", Number)
], ParkingHistory.prototype, "durationMinutes", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'User rating for the parking experience' }),
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
__metadata("design:type", Number)
], ParkingHistory.prototype, "rating", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'User review comments' }),
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
__metadata("design:type", String)
], ParkingHistory.prototype, "review", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.parkingHistory, { nullable: true }),
(0, typeorm_1.JoinColumn)({ name: 'userId' }),
__metadata("design:type", user_entity_1.User)
], ParkingHistory.prototype, "user", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => parking_lot_entity_1.ParkingLot, (parkingLot) => parkingLot.history),
(0, typeorm_1.JoinColumn)({ name: 'parkingLotId' }),
__metadata("design:type", parking_lot_entity_1.ParkingLot)
], ParkingHistory.prototype, "parkingLot", void 0);
exports.ParkingHistory = ParkingHistory = __decorate([
(0, typeorm_1.Entity)('parking_history')
], ParkingHistory);
//# sourceMappingURL=parking-history.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parking-history.entity.js","sourceRoot":"","sources":["../../../../src/modules/parking/entities/parking-history.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AACjB,6CAA8C;AAC9C,kEAAwD;AACxD,6DAAkD;AAG3C,IAAM,cAAc,GAApB,MAAM,cAAc;CAqC1B,CAAA;AArCY,wCAAc;AAGzB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;IAC/E,IAAA,gCAAsB,GAAE;;0CACd;AAIX;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IAChE,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAC1B;AAIf;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC5D,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;oDACH;AAIrB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IAC1D,IAAA,0BAAgB,GAAE;8BACR,IAAI;iDAAC;AAIhB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IAC9D,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDAChB;AAIxB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IACtE,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACzB;AAIf;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACpD,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAC1B;AAKf;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;8BACzB,kBAAI;4CAAC;AAIX;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAU,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;IAC/D,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;8BACzB,+BAAU;kDAAC;yBApCZ,cAAc;IAD1B,IAAA,gBAAM,EAAC,iBAAiB,CAAC;GACb,cAAc,CAqC1B"}

View File

@@ -0,0 +1,25 @@
import { ParkingHistory } from './parking-history.entity';
import { ParkingUpdate } from './parking-update.entity';
export declare class ParkingLot {
id: number;
name: string;
address: string;
lat: number;
lng: number;
location: string;
hourlyRate: number;
openTime: string;
closeTime: string;
availableSlots: number;
totalSlots: number;
amenities: Record<string, any>;
contactInfo: Record<string, any>;
isActive: boolean;
createdAt: Date;
updatedAt: Date;
history: ParkingHistory[];
updates: ParkingUpdate[];
get occupancyRate(): number;
get availabilityStatus(): 'available' | 'limited' | 'full';
get isOpen(): boolean;
}

View File

@@ -0,0 +1,155 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParkingLot = void 0;
const typeorm_1 = require("typeorm");
const swagger_1 = require("@nestjs/swagger");
const parking_history_entity_1 = require("./parking-history.entity");
const parking_update_entity_1 = require("./parking-update.entity");
let ParkingLot = class ParkingLot {
get occupancyRate() {
if (this.totalSlots === 0)
return 0;
return ((this.totalSlots - this.availableSlots) / this.totalSlots) * 100;
}
get availabilityStatus() {
const rate = this.occupancyRate;
if (rate >= 95)
return 'full';
if (rate >= 80)
return 'limited';
return 'available';
}
get isOpen() {
if (!this.openTime || !this.closeTime)
return true;
const now = new Date();
const currentTime = now.getHours() * 60 + now.getMinutes();
const [openHour, openMin] = this.openTime.split(':').map(Number);
const [closeHour, closeMin] = this.closeTime.split(':').map(Number);
const openMinutes = openHour * 60 + openMin;
const closeMinutes = closeHour * 60 + closeMin;
return currentTime >= openMinutes && currentTime <= closeMinutes;
}
};
exports.ParkingLot = ParkingLot;
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Unique identifier for the parking lot' }),
(0, typeorm_1.PrimaryGeneratedColumn)(),
__metadata("design:type", Number)
], ParkingLot.prototype, "id", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Name of the parking lot' }),
(0, typeorm_1.Column)({ type: 'varchar', length: 255 }),
__metadata("design:type", String)
], ParkingLot.prototype, "name", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Address of the parking lot' }),
(0, typeorm_1.Column)({ type: 'text' }),
__metadata("design:type", String)
], ParkingLot.prototype, "address", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Latitude coordinate' }),
(0, typeorm_1.Column)({ type: 'double precision' }),
__metadata("design:type", Number)
], ParkingLot.prototype, "lat", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Longitude coordinate' }),
(0, typeorm_1.Column)({ type: 'double precision' }),
__metadata("design:type", Number)
], ParkingLot.prototype, "lng", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'PostGIS geography point' }),
(0, typeorm_1.Column)({
type: 'geography',
spatialFeatureType: 'Point',
srid: 4326,
nullable: true,
}),
__metadata("design:type", String)
], ParkingLot.prototype, "location", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Hourly parking rate' }),
(0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 2, nullable: true }),
__metadata("design:type", Number)
], ParkingLot.prototype, "hourlyRate", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Opening time' }),
(0, typeorm_1.Column)({ type: 'time', nullable: true }),
__metadata("design:type", String)
], ParkingLot.prototype, "openTime", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Closing time' }),
(0, typeorm_1.Column)({ type: 'time', nullable: true }),
__metadata("design:type", String)
], ParkingLot.prototype, "closeTime", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Number of available parking spaces' }),
(0, typeorm_1.Column)({ type: 'int', default: 0 }),
__metadata("design:type", Number)
], ParkingLot.prototype, "availableSlots", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Total number of parking spaces' }),
(0, typeorm_1.Column)({ type: 'int' }),
__metadata("design:type", Number)
], ParkingLot.prototype, "totalSlots", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Parking lot amenities' }),
(0, typeorm_1.Column)({ type: 'jsonb', default: '{}' }),
__metadata("design:type", Object)
], ParkingLot.prototype, "amenities", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Contact information' }),
(0, typeorm_1.Column)({ type: 'jsonb', default: '{}' }),
__metadata("design:type", Object)
], ParkingLot.prototype, "contactInfo", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Whether the parking lot is active' }),
(0, typeorm_1.Column)({ type: 'boolean', default: true }),
__metadata("design:type", Boolean)
], ParkingLot.prototype, "isActive", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Creation timestamp' }),
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], ParkingLot.prototype, "createdAt", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Last update timestamp' }),
(0, typeorm_1.UpdateDateColumn)(),
__metadata("design:type", Date)
], ParkingLot.prototype, "updatedAt", void 0);
__decorate([
(0, typeorm_1.OneToMany)(() => parking_history_entity_1.ParkingHistory, (history) => history.parkingLot),
__metadata("design:type", Array)
], ParkingLot.prototype, "history", void 0);
__decorate([
(0, typeorm_1.OneToMany)(() => parking_update_entity_1.ParkingUpdate, (update) => update.parkingLot),
__metadata("design:type", Array)
], ParkingLot.prototype, "updates", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Occupancy rate as percentage' }),
__metadata("design:type", Number),
__metadata("design:paramtypes", [])
], ParkingLot.prototype, "occupancyRate", null);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Availability status' }),
__metadata("design:type", String),
__metadata("design:paramtypes", [])
], ParkingLot.prototype, "availabilityStatus", null);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Whether the parking lot is currently open' }),
__metadata("design:type", Boolean),
__metadata("design:paramtypes", [])
], ParkingLot.prototype, "isOpen", null);
exports.ParkingLot = ParkingLot = __decorate([
(0, typeorm_1.Entity)('parking_lots')
], ParkingLot);
//# sourceMappingURL=parking-lot.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parking-lot.entity.js","sourceRoot":"","sources":["../../../../src/modules/parking/entities/parking-lot.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AACjB,6CAA8C;AAC9C,qEA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ACR,IAAI;6CAAC;AAIhB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;;2CACvC;AAG1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;;2CACrC;AAGzB;IAAC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;;;+CAI5D;AAED;IAAC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;;;oDAMnD;AAED;IAAC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;;;wCAczE;qBA1GU,UAAU;IADtB,IAAA,gBAAM,EAAC,cAAc,CAAC;GACV,UAAU,CA2GtB"}

View File

@@ -0,0 +1,11 @@
import { ParkingLot } from './parking-lot.entity';
export declare class ParkingUpdate {
id: number;
parkingLotId: number;
availableSlots: number;
source: string;
confidence: number;
metadata: Record<string, any>;
timestamp: Date;
parkingLot: ParkingLot;
}

View File

@@ -0,0 +1,62 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParkingUpdate = void 0;
const typeorm_1 = require("typeorm");
const swagger_1 = require("@nestjs/swagger");
const parking_lot_entity_1 = require("./parking-lot.entity");
let ParkingUpdate = class ParkingUpdate {
};
exports.ParkingUpdate = ParkingUpdate;
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Unique identifier for the parking update' }),
(0, typeorm_1.PrimaryGeneratedColumn)(),
__metadata("design:type", Number)
], ParkingUpdate.prototype, "id", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Parking lot being updated' }),
(0, typeorm_1.Column)({ type: 'int' }),
__metadata("design:type", Number)
], ParkingUpdate.prototype, "parkingLotId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Number of available slots at time of update' }),
(0, typeorm_1.Column)({ type: 'int' }),
__metadata("design:type", Number)
], ParkingUpdate.prototype, "availableSlots", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Source of the update' }),
(0, typeorm_1.Column)({ type: 'varchar', length: 50, default: 'sensor' }),
__metadata("design:type", String)
], ParkingUpdate.prototype, "source", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Confidence level of the update (0-1)' }),
(0, typeorm_1.Column)({ type: 'decimal', precision: 3, scale: 2, default: 1.0 }),
__metadata("design:type", Number)
], ParkingUpdate.prototype, "confidence", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Additional metadata for the update' }),
(0, typeorm_1.Column)({ type: 'jsonb', default: '{}' }),
__metadata("design:type", Object)
], ParkingUpdate.prototype, "metadata", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Timestamp of the update' }),
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], ParkingUpdate.prototype, "timestamp", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => parking_lot_entity_1.ParkingLot, (parkingLot) => parkingLot.updates),
(0, typeorm_1.JoinColumn)({ name: 'parkingLotId' }),
__metadata("design:type", parking_lot_entity_1.ParkingLot)
], ParkingUpdate.prototype, "parkingLot", void 0);
exports.ParkingUpdate = ParkingUpdate = __decorate([
(0, typeorm_1.Entity)('parking_updates')
], ParkingUpdate);
//# sourceMappingURL=parking-update.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parking-update.entity.js","sourceRoot":"","sources":["../../../../src/modules/parking/entities/parking-update.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AACjB,6CAA8C;AAC9C,6DAAkD;AAG3C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAiCzB,CAAA;AAjCY,sCAAa;AAGxB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;IACxE,IAAA,gCAAsB,GAAE;;yCACd;AAIX;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;IACzD,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;mDACH;AAIrB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;IAC3E,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;qDACD;AAIvB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACpD,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;6CAC5C;AAIf;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;IACpE,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;;iDAC/C;AAInB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;IAClE,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;+CACX;AAI9B;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACvD,IAAA,0BAAgB,GAAE;8BACR,IAAI;gDAAC;AAKhB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAU,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;IAC/D,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;8BACzB,+BAAU;iDAAC;wBAhCZ,aAAa;IADzB,IAAA,gBAAM,EAAC,iBAAiB,CAAC;GACb,aAAa,CAiCzB"}

View File

@@ -0,0 +1,22 @@
import { ParkingService } from './parking.service';
import { FindNearbyParkingDto } from './dto/find-nearby-parking.dto';
import { UpdateParkingAvailabilityDto } from './dto/update-availability.dto';
import { ParkingLot } from './entities/parking-lot.entity';
import { ParkingUpdate } from './entities/parking-update.entity';
export declare class ParkingController {
private readonly parkingService;
constructor(parkingService: ParkingService);
findNearbyParking(dto: FindNearbyParkingDto): Promise<{
parkingLots: ParkingLot[];
userLocation: {
lat: number;
lng: number;
};
searchRadius: number;
}>;
getAllParkingLots(): Promise<ParkingLot[]>;
getPopularParkingLots(limit?: number): Promise<ParkingLot[]>;
getParkingLotById(id: number): Promise<ParkingLot>;
updateAvailability(id: number, dto: UpdateParkingAvailabilityDto): Promise<ParkingLot>;
getParkingLotHistory(id: number, limit?: number): Promise<ParkingUpdate[]>;
}

View File

@@ -0,0 +1,207 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParkingController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const throttler_1 = require("@nestjs/throttler");
const parking_service_1 = require("./parking.service");
const find_nearby_parking_dto_1 = require("./dto/find-nearby-parking.dto");
const update_availability_dto_1 = require("./dto/update-availability.dto");
const parking_lot_entity_1 = require("./entities/parking-lot.entity");
const parking_update_entity_1 = require("./entities/parking-update.entity");
let ParkingController = class ParkingController {
constructor(parkingService) {
this.parkingService = parkingService;
}
async findNearbyParking(dto) {
return this.parkingService.findNearbyParking(dto);
}
async getAllParkingLots() {
return this.parkingService.getAllParkingLots();
}
async getPopularParkingLots(limit) {
return this.parkingService.getPopularParkingLots(limit);
}
async getParkingLotById(id) {
return this.parkingService.findById(id);
}
async updateAvailability(id, dto) {
return this.parkingService.updateAvailability(id, dto);
}
async getParkingLotHistory(id, limit) {
return this.parkingService.getParkingLotHistory(id, limit);
}
};
exports.ParkingController = ParkingController;
__decorate([
(0, common_1.Post)('nearby'),
(0, swagger_1.ApiOperation)({
summary: 'Find nearby parking lots',
description: 'Search for parking lots within a specified radius of the given coordinates'
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Successfully found nearby parking lots',
type: parking_lot_entity_1.ParkingLot,
isArray: true,
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.BAD_REQUEST,
description: 'Invalid coordinates or parameters',
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
description: 'Failed to search for parking lots',
}),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [find_nearby_parking_dto_1.FindNearbyParkingDto]),
__metadata("design:returntype", Promise)
], ParkingController.prototype, "findNearbyParking", null);
__decorate([
(0, common_1.Get)(),
(0, swagger_1.ApiOperation)({
summary: 'Get all parking lots',
description: 'Retrieve all active parking lots in the system'
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Successfully retrieved parking lots',
type: parking_lot_entity_1.ParkingLot,
isArray: true,
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], ParkingController.prototype, "getAllParkingLots", null);
__decorate([
(0, common_1.Get)('popular'),
(0, swagger_1.ApiOperation)({
summary: 'Get popular parking lots',
description: 'Retrieve the most frequently visited parking lots'
}),
(0, swagger_1.ApiQuery)({
name: 'limit',
required: false,
description: 'Maximum number of results',
example: 10
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Successfully retrieved popular parking lots',
type: parking_lot_entity_1.ParkingLot,
isArray: true,
}),
__param(0, (0, common_1.Query)('limit')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], ParkingController.prototype, "getPopularParkingLots", null);
__decorate([
(0, common_1.Get)(':id'),
(0, swagger_1.ApiOperation)({
summary: 'Get parking lot details',
description: 'Retrieve detailed information about a specific parking lot'
}),
(0, swagger_1.ApiParam)({
name: 'id',
description: 'Parking lot ID',
example: 1
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Successfully retrieved parking lot details',
type: parking_lot_entity_1.ParkingLot,
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.NOT_FOUND,
description: 'Parking lot not found',
}),
__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], ParkingController.prototype, "getParkingLotById", null);
__decorate([
(0, common_1.Put)(':id/availability'),
(0, swagger_1.ApiBearerAuth)(),
(0, swagger_1.ApiOperation)({
summary: 'Update parking availability',
description: 'Update the number of available slots for a parking lot'
}),
(0, swagger_1.ApiParam)({
name: 'id',
description: 'Parking lot ID',
example: 1
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Successfully updated parking availability',
type: parking_lot_entity_1.ParkingLot,
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.NOT_FOUND,
description: 'Parking lot not found',
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.BAD_REQUEST,
description: 'Invalid availability data',
}),
__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, update_availability_dto_1.UpdateParkingAvailabilityDto]),
__metadata("design:returntype", Promise)
], ParkingController.prototype, "updateAvailability", null);
__decorate([
(0, common_1.Get)(':id/history'),
(0, swagger_1.ApiOperation)({
summary: 'Get parking lot update history',
description: 'Retrieve the update history for a specific parking lot'
}),
(0, swagger_1.ApiParam)({
name: 'id',
description: 'Parking lot ID',
example: 1
}),
(0, swagger_1.ApiQuery)({
name: 'limit',
required: false,
description: 'Maximum number of history records',
example: 100
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Successfully retrieved parking lot history',
type: parking_update_entity_1.ParkingUpdate,
isArray: true,
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.NOT_FOUND,
description: 'Parking lot not found',
}),
__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
__param(1, (0, common_1.Query)('limit')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, Number]),
__metadata("design:returntype", Promise)
], ParkingController.prototype, "getParkingLotHistory", null);
exports.ParkingController = ParkingController = __decorate([
(0, swagger_1.ApiTags)('Parking'),
(0, common_1.Controller)('parking'),
(0, common_1.UseGuards)(throttler_1.ThrottlerGuard),
__metadata("design:paramtypes", [parking_service_1.ParkingService])
], ParkingController);
//# sourceMappingURL=parking.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"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A1BL,IAAA,YAAG,EAAC,aAAa,CAAC;IAClB,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,gCAAgC;QACzC,WAAW,EAAE,wDAAwD;KACtE,CAAC;IACD,IAAA,kBAAQ,EAAC;QACR,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,gBAAgB;QAC7B,OAAO,EAAE,CAAC;KACX,CAAC;IACD,IAAA,kBAAQ,EAAC;QACR,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,GAAG;KACb,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,mBAAU,CAAC,EAAE;QACrB,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,qCAAa;QACnB,OAAO,EAAE,IAAI;KACd,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,mBAAU,CAAC,SAAS;QAC5B,WAAW,EAAE,uBAAuB;KACrC,CAAC;IAEC,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;IACzB,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;;;;6DAGhB;4BAnJU,iBAAiB;IAH7B,IAAA,iBAAO,EAAC,SAAS,CAAC;IAClB,IAAA,mBAAU,EAAC,SAAS,CAAC;IACrB,IAAA,kBAAS,EAAC,0BAAc,CAAC;qCAEqB,gCAAc;GADhD,iBAAiB,CAoJ7B"}

View File

@@ -0,0 +1,2 @@
export declare class ParkingModule {
}

View File

@@ -0,0 +1,34 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParkingModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const parking_controller_1 = require("./parking.controller");
const parking_service_1 = require("./parking.service");
const parking_lot_entity_1 = require("./entities/parking-lot.entity");
const parking_history_entity_1 = require("./entities/parking-history.entity");
const parking_update_entity_1 = require("./entities/parking-update.entity");
let ParkingModule = class ParkingModule {
};
exports.ParkingModule = ParkingModule;
exports.ParkingModule = ParkingModule = __decorate([
(0, common_1.Module)({
imports: [
typeorm_1.TypeOrmModule.forFeature([
parking_lot_entity_1.ParkingLot,
parking_history_entity_1.ParkingHistory,
parking_update_entity_1.ParkingUpdate,
]),
],
controllers: [parking_controller_1.ParkingController],
providers: [parking_service_1.ParkingService],
exports: [parking_service_1.ParkingService],
})
], ParkingModule);
//# sourceMappingURL=parking.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parking.module.js","sourceRoot":"","sources":["../../../src/modules/parking/parking.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6DAAyD;AACzD,uDAAmD;AACnD,sEAA2D;AAC3D,8EAAmE;AACnE,4EAAiE;AAc1D,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IAZzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC;gBACvB,+BAAU;gBACV,uCAAc;gBACd,qCAAa;aACd,CAAC;SACH;QACD,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,SAAS,EAAE,CAAC,gCAAc,CAAC;QAC3B,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"}

View File

@@ -0,0 +1,24 @@
import { Repository } from 'typeorm';
import { ParkingLot } from './entities/parking-lot.entity';
import { ParkingUpdate } from './entities/parking-update.entity';
import { FindNearbyParkingDto } from './dto/find-nearby-parking.dto';
import { UpdateParkingAvailabilityDto } from './dto/update-availability.dto';
export declare class ParkingService {
private readonly parkingRepository;
private readonly updateRepository;
private readonly logger;
constructor(parkingRepository: Repository<ParkingLot>, updateRepository: Repository<ParkingUpdate>);
findNearbyParking(dto: FindNearbyParkingDto): Promise<{
parkingLots: ParkingLot[];
userLocation: {
lat: number;
lng: number;
};
searchRadius: number;
}>;
findById(id: number): Promise<ParkingLot>;
updateAvailability(id: number, dto: UpdateParkingAvailabilityDto): Promise<ParkingLot>;
getAllParkingLots(): Promise<ParkingLot[]>;
getParkingLotHistory(id: number, limit?: number): Promise<ParkingUpdate[]>;
getPopularParkingLots(limit?: number): Promise<ParkingLot[]>;
}

View File

@@ -0,0 +1,148 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var ParkingService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParkingService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const typeorm_2 = require("typeorm");
const parking_lot_entity_1 = require("./entities/parking-lot.entity");
const parking_update_entity_1 = require("./entities/parking-update.entity");
let ParkingService = ParkingService_1 = class ParkingService {
constructor(parkingRepository, updateRepository) {
this.parkingRepository = parkingRepository;
this.updateRepository = updateRepository;
this.logger = new common_1.Logger(ParkingService_1.name);
}
async findNearbyParking(dto) {
try {
this.logger.debug(`Finding parking near ${dto.lat}, ${dto.lng} within ${dto.radius}m`);
let query = this.parkingRepository
.createQueryBuilder('lot')
.select([
'lot.*',
'ST_Distance(lot.location::geography, ST_Point(:lng, :lat)::geography) as distance'
])
.where('ST_DWithin(lot.location::geography, ST_Point(:lng, :lat)::geography, :radius)', {
lng: dto.lng,
lat: dto.lat,
radius: dto.radius,
})
.andWhere('lot.isActive = :isActive', { isActive: true });
if (dto.priceRange && dto.priceRange.length === 2) {
query = query.andWhere('lot.hourlyRate BETWEEN :minPrice AND :maxPrice', { minPrice: dto.priceRange[0], maxPrice: dto.priceRange[1] });
}
if (dto.amenities && dto.amenities.length > 0) {
dto.amenities.forEach((amenity, index) => {
query = query.andWhere(`lot.amenities ? :amenity${index}`, { [`amenity${index}`]: amenity });
});
}
if (dto.availabilityFilter) {
switch (dto.availabilityFilter) {
case 'available':
query = query.andWhere('(lot.availableSlots::float / lot.totalSlots::float) > 0.2');
break;
case 'limited':
query = query.andWhere('(lot.availableSlots::float / lot.totalSlots::float) BETWEEN 0.05 AND 0.2');
break;
case 'full':
query = query.andWhere('(lot.availableSlots::float / lot.totalSlots::float) < 0.05');
break;
}
}
const results = await query
.orderBy('distance', 'ASC')
.limit(dto.maxResults)
.getRawMany();
const parkingLots = results.map((result) => {
const { distance, ...lotData } = result;
const lot = this.parkingRepository.create(lotData);
lot.distance = parseFloat(distance);
return lot;
});
return {
parkingLots,
userLocation: { lat: dto.lat, lng: dto.lng },
searchRadius: dto.radius,
};
}
catch (error) {
this.logger.error('Failed to find nearby parking', error);
throw new common_1.InternalServerErrorException('Failed to find nearby parking');
}
}
async findById(id) {
const lot = await this.parkingRepository.findOne({
where: { id },
relations: ['updates'],
});
if (!lot) {
throw new common_1.NotFoundException(`Parking lot with ID ${id} not found`);
}
return lot;
}
async updateAvailability(id, dto) {
const lot = await this.findById(id);
const update = this.updateRepository.create({
parkingLotId: id,
availableSlots: dto.availableSlots,
source: dto.source,
confidence: dto.confidence,
metadata: dto.metadata,
});
await this.updateRepository.save(update);
lot.availableSlots = dto.availableSlots;
lot.updatedAt = new Date();
return this.parkingRepository.save(lot);
}
async getAllParkingLots() {
return this.parkingRepository.find({
where: { isActive: true },
order: { name: 'ASC' },
});
}
async getParkingLotHistory(id, limit = 100) {
return this.updateRepository.find({
where: { parkingLotId: id },
order: { timestamp: 'DESC' },
take: limit,
});
}
async getPopularParkingLots(limit = 10) {
const results = await this.parkingRepository
.createQueryBuilder('lot')
.leftJoin('lot.history', 'history')
.select(['lot.*', 'COUNT(history.id) as visit_count'])
.where('lot.isActive = :isActive', { isActive: true })
.groupBy('lot.id')
.orderBy('visit_count', 'DESC')
.limit(limit)
.getRawMany();
return results.map((result) => {
const { visit_count, ...lotData } = result;
const lot = this.parkingRepository.create(lotData);
lot.visitCount = parseInt(visit_count) || 0;
return lot;
});
}
};
exports.ParkingService = ParkingService;
exports.ParkingService = ParkingService = ParkingService_1 = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(parking_lot_entity_1.ParkingLot)),
__param(1, (0, typeorm_1.InjectRepository)(parking_update_entity_1.ParkingUpdate)),
__metadata("design:paramtypes", [typeorm_2.Repository,
typeorm_2.Repository])
], ParkingService);
//# sourceMappingURL=parking.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parking.service.js","sourceRoot":"","sources":["../../../src/modules/parking/parking.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAqG;AACrG,6CAAmD;AACnD,qCAAqC;AACrC,sEAA2D;AAC3D,4EAAiE;AAK1D,IAAM,cAAc,sBAApB,MAAM,cAAc;IAGzB,YAEE,iBAA0D,EAE1D,gBAA4D;QAF3C,sBAAiB,GAAjB,iBAAiB,CAAwB;QAEzC,qBAAgB,GAAhB,gBAAgB,CAA2B;QAN7C,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,I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@ -0,0 +1,37 @@
export declare class RouteRequestDto {
originLat: number;
originLng: number;
destinationLat: number;
destinationLng: number;
costing?: 'auto' | 'bicycle' | 'pedestrian';
alternatives?: number;
avoidHighways?: boolean;
avoidTolls?: boolean;
}
export interface RoutePoint {
lat: number;
lng: number;
}
export interface RouteStep {
instruction: string;
distance: number;
time: number;
type: string;
geometry: RoutePoint[];
}
export interface Route {
summary: {
distance: number;
time: number;
cost?: number;
};
geometry: RoutePoint[];
steps: RouteStep[];
confidence: number;
}
export interface RouteResponse {
routes: Route[];
origin: RoutePoint;
destination: RoutePoint;
requestId: string;
}

View File

@@ -0,0 +1,121 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RouteRequestDto = void 0;
const swagger_1 = require("@nestjs/swagger");
const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
class RouteRequestDto {
constructor() {
this.costing = 'auto';
this.alternatives = 1;
this.avoidHighways = false;
this.avoidTolls = false;
}
}
exports.RouteRequestDto = RouteRequestDto;
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Origin latitude',
example: 1.3521,
minimum: -90,
maximum: 90
}),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(-90),
(0, class_validator_1.Max)(90),
(0, class_transformer_1.Transform)(({ value }) => parseFloat(value)),
__metadata("design:type", Number)
], RouteRequestDto.prototype, "originLat", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Origin longitude',
example: 103.8198,
minimum: -180,
maximum: 180
}),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(-180),
(0, class_validator_1.Max)(180),
(0, class_transformer_1.Transform)(({ value }) => parseFloat(value)),
__metadata("design:type", Number)
], RouteRequestDto.prototype, "originLng", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Destination latitude',
example: 1.3500,
minimum: -90,
maximum: 90
}),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(-90),
(0, class_validator_1.Max)(90),
(0, class_transformer_1.Transform)(({ value }) => parseFloat(value)),
__metadata("design:type", Number)
], RouteRequestDto.prototype, "destinationLat", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Destination longitude',
example: 103.8150,
minimum: -180,
maximum: 180
}),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(-180),
(0, class_validator_1.Max)(180),
(0, class_transformer_1.Transform)(({ value }) => parseFloat(value)),
__metadata("design:type", Number)
], RouteRequestDto.prototype, "destinationLng", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Transportation mode',
example: 'auto',
enum: ['auto', 'bicycle', 'pedestrian'],
required: false
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsEnum)(['auto', 'bicycle', 'pedestrian']),
__metadata("design:type", String)
], RouteRequestDto.prototype, "costing", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Number of alternative routes',
example: 2,
minimum: 0,
maximum: 3,
required: false
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsNumber)(),
(0, class_validator_1.Min)(0),
(0, class_validator_1.Max)(3),
(0, class_transformer_1.Transform)(({ value }) => parseInt(value)),
__metadata("design:type", Number)
], RouteRequestDto.prototype, "alternatives", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Avoid highways',
example: false,
required: false
}),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Boolean)
], RouteRequestDto.prototype, "avoidHighways", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: 'Avoid tolls',
example: false,
required: false
}),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Boolean)
], RouteRequestDto.prototype, "avoidTolls", void 0);
//# sourceMappingURL=route-request.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"route-request.dto.js","sourceRoot":"","sources":["../../../../src/modules/routing/dto/route-request.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAyE;AACzE,yDAA8C;AAE9C,MAAa,eAAe;IAA5B;QAyDE,YAAO,GAAuC,MAAM,CAAC;QAcrD,iBAAY,GAAY,CAAC,CAAC;QAQ1B,kBAAa,GAAa,KAAK,CAAC;QAQhC,eAAU,GAAa,KAAK,CAAC;IAC/B,CAAC;CAAA;AAxFD,0CAwFC;AA7EC;IAVC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,CAAC,EAAE;QACZ,OAAO,EAAE,EAAE;KACZ,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,EAAE,CAAC;IACR,IAAA,qBAAG,EAAC,EAAE,CAAC;IACP,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;;kDAC1B;AAYlB;IAVC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,CAAC,GAAG;QACb,OAAO,EAAE,GAAG;KACb,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,GAAG,CAAC;IACT,IAAA,qBAAG,EAAC,GAAG,CAAC;IACR,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,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E;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;;qDAChB;AAQ1B;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,gBAAgB;QAC7B,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;;sDACmB;AAQhC;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,aAAa;QAC1B,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;;mDACgB"}

View File

@@ -0,0 +1,11 @@
import { RoutingService } from './routing.service';
import { RouteRequestDto, RouteResponse } from './dto/route-request.dto';
export declare class RoutingController {
private readonly routingService;
constructor(routingService: RoutingService);
calculateRoute(dto: RouteRequestDto): Promise<RouteResponse>;
getServiceStatus(): Promise<{
status: string;
version?: string;
}>;
}

View File

@@ -0,0 +1,88 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoutingController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const throttler_1 = require("@nestjs/throttler");
const routing_service_1 = require("./routing.service");
const route_request_dto_1 = require("./dto/route-request.dto");
let RoutingController = class RoutingController {
constructor(routingService) {
this.routingService = routingService;
}
async calculateRoute(dto) {
return this.routingService.calculateRoute(dto);
}
async getServiceStatus() {
return this.routingService.getServiceStatus();
}
};
exports.RoutingController = RoutingController;
__decorate([
(0, common_1.Post)('calculate'),
(0, swagger_1.ApiOperation)({
summary: 'Calculate route between two points',
description: 'Generate turn-by-turn directions using Valhalla routing engine'
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Successfully calculated route',
type: 'object',
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.BAD_REQUEST,
description: 'Invalid route parameters',
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.NOT_FOUND,
description: 'No route found between the specified locations',
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.SERVICE_UNAVAILABLE,
description: 'Routing service unavailable',
}),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [route_request_dto_1.RouteRequestDto]),
__metadata("design:returntype", Promise)
], RoutingController.prototype, "calculateRoute", null);
__decorate([
(0, common_1.Get)('status'),
(0, swagger_1.ApiOperation)({
summary: 'Check routing service status',
description: 'Check if the Valhalla routing service is healthy and responsive'
}),
(0, swagger_1.ApiResponse)({
status: common_1.HttpStatus.OK,
description: 'Service status information',
schema: {
type: 'object',
properties: {
status: { type: 'string', example: 'healthy' },
version: { type: 'string', example: '3.1.0' },
},
},
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], RoutingController.prototype, "getServiceStatus", null);
exports.RoutingController = RoutingController = __decorate([
(0, swagger_1.ApiTags)('Routing'),
(0, common_1.Controller)('routing'),
(0, common_1.UseGuards)(throttler_1.ThrottlerGuard),
__metadata("design:paramtypes", [routing_service_1.RoutingService])
], RoutingController);
//# sourceMappingURL=routing.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"routing.controller.js","sourceRoot":"","sources":["../../../src/modules/routing/routing.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAOwB;AACxB,6CAIyB;AACzB,iDAAmD;AACnD,uDAAmD;AACnD,+DAAyE;AAKlE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAwBzD,AAAN,KAAK,CAAC,cAAc,CAAS,GAAoB;QAC/C,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAkBK,AAAN,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAChD,CAAC;CACF,CAAA;AAhDY,8CAAiB;AAyBtB;IAtBL,IAAA,aAAI,EAAC,WAAW,CAAC;IACjB,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,oCAAoC;QAC7C,WAAW,EAAE,gEAAgE;KAC9E,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,mBAAU,CAAC,EAAE;QACrB,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,QAAQ;KACf,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,mBAAU,CAAC,WAAW;QAC9B,WAAW,EAAE,0BAA0B;KACxC,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,mBAAU,CAAC,SAAS;QAC5B,WAAW,EAAE,gDAAgD;KAC9D,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,mBAAU,CAAC,mBAAmB;QACtC,WAAW,EAAE,6BAA6B;KAC3C,CAAC;IACoB,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,mCAAe;;uDAEhD;AAkBK;IAhBL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,8BAA8B;QACvC,WAAW,EAAE,iEAAiE;KAC/E,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,mBAAU,CAAC,EAAE;QACrB,WAAW,EAAE,4BAA4B;QACzC,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE;gBAC9C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE;aAC9C;SACF;KACF,CAAC;;;;yDAGD;4BA/CU,iBAAiB;IAH7B,IAAA,iBAAO,EAAC,SAAS,CAAC;IAClB,IAAA,mBAAU,EAAC,SAAS,CAAC;IACrB,IAAA,kBAAS,EAAC,0BAAc,CAAC;qCAEqB,gCAAc;GADhD,iBAAiB,CAgD7B"}

View File

@@ -0,0 +1,2 @@
export declare class RoutingModule {
}

View File

@@ -0,0 +1,23 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoutingModule = void 0;
const common_1 = require("@nestjs/common");
const routing_controller_1 = require("./routing.controller");
const routing_service_1 = require("./routing.service");
let RoutingModule = class RoutingModule {
};
exports.RoutingModule = RoutingModule;
exports.RoutingModule = RoutingModule = __decorate([
(0, common_1.Module)({
controllers: [routing_controller_1.RoutingController],
providers: [routing_service_1.RoutingService],
exports: [routing_service_1.RoutingService],
})
], RoutingModule);
//# sourceMappingURL=routing.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"routing.module.js","sourceRoot":"","sources":["../../../src/modules/routing/routing.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6DAAyD;AACzD,uDAAmD;AAO5C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IALzB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,SAAS,EAAE,CAAC,gCAAc,CAAC;QAC3B,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"}

View File

@@ -0,0 +1,21 @@
import { ConfigService } from '@nestjs/config';
import { RouteRequestDto, RouteResponse } from './dto/route-request.dto';
export declare class RoutingService {
private configService;
private readonly logger;
private readonly valhallaClient;
private readonly valhallaUrl;
constructor(configService: ConfigService);
calculateRoute(dto: RouteRequestDto): Promise<RouteResponse>;
private buildValhallaRequest;
private getCostingOptions;
private parseValhallaResponse;
private parseManeuvers;
private decodePolyline;
private estimateFuelCost;
private generateRequestId;
getServiceStatus(): Promise<{
status: string;
version?: string;
}>;
}

View File

@@ -0,0 +1,206 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var RoutingService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoutingService = void 0;
const common_1 = require("@nestjs/common");
const config_1 = require("@nestjs/config");
const axios_1 = require("axios");
let RoutingService = RoutingService_1 = class RoutingService {
constructor(configService) {
this.configService = configService;
this.logger = new common_1.Logger(RoutingService_1.name);
this.valhallaUrl = this.configService.get('VALHALLA_URL') || 'http://valhalla:8002';
this.valhallaClient = axios_1.default.create({
baseURL: this.valhallaUrl,
timeout: 30000,
headers: {
'Content-Type': 'application/json',
},
});
}
async calculateRoute(dto) {
try {
this.logger.debug(`Calculating route from ${dto.originLat},${dto.originLng} to ${dto.destinationLat},${dto.destinationLng}`);
const requestId = this.generateRequestId();
const valhallaRequest = this.buildValhallaRequest(dto);
const response = await this.valhallaClient.post('/route', valhallaRequest);
if (!response.data || !response.data.trip) {
throw new Error('Invalid response from Valhalla routing engine');
}
const routes = this.parseValhallaResponse(response.data);
return {
routes,
origin: { lat: dto.originLat, lng: dto.originLng },
destination: { lat: dto.destinationLat, lng: dto.destinationLng },
requestId,
};
}
catch (error) {
this.logger.error('Failed to calculate route', error);
if (error.response?.status === 400) {
throw new common_1.HttpException('Invalid route request parameters', common_1.HttpStatus.BAD_REQUEST);
}
if (error.response?.status === 404) {
throw new common_1.HttpException('No route found between the specified locations', common_1.HttpStatus.NOT_FOUND);
}
throw new common_1.HttpException('Route calculation service unavailable', common_1.HttpStatus.SERVICE_UNAVAILABLE);
}
}
buildValhallaRequest(dto) {
const locations = [
{ lat: dto.originLat, lon: dto.originLng },
{ lat: dto.destinationLat, lon: dto.destinationLng },
];
const costingOptions = this.getCostingOptions(dto);
return {
locations,
costing: dto.costing,
costing_options: costingOptions,
directions_options: {
units: 'kilometers',
language: 'en-US',
narrative: true,
alternates: dto.alternatives || 1,
},
format: 'json',
shape_match: 'edge_walk',
encoded_polyline: true,
};
}
getCostingOptions(dto) {
const options = {};
if (dto.costing === 'auto') {
options.auto = {
maneuver_penalty: 5,
gate_cost: 30,
gate_penalty: 300,
private_access_penalty: 450,
toll_booth_cost: 15,
toll_booth_penalty: 0,
ferry_cost: 300,
use_ferry: dto.avoidTolls ? 0 : 1,
use_highways: dto.avoidHighways ? 0 : 1,
use_tolls: dto.avoidTolls ? 0 : 1,
};
}
else if (dto.costing === 'bicycle') {
options.bicycle = {
maneuver_penalty: 5,
gate_penalty: 300,
use_roads: 0.5,
use_hills: 0.5,
use_ferry: 1,
avoid_bad_surfaces: 0.25,
};
}
else if (dto.costing === 'pedestrian') {
options.pedestrian = {
walking_speed: 5.1,
walkway_factor: 1,
sidewalk_factor: 1,
alley_factor: 2,
driveway_factor: 5,
step_penalty: 0,
use_ferry: 1,
use_living_streets: 0.6,
};
}
return options;
}
parseValhallaResponse(data) {
const trip = data.trip;
if (!trip || !trip.legs || trip.legs.length === 0) {
return [];
}
const route = {
summary: {
distance: Math.round(trip.summary.length * 100) / 100,
time: Math.round(trip.summary.time / 60 * 100) / 100,
cost: this.estimateFuelCost(trip.summary.length, 'auto'),
},
geometry: this.decodePolyline(trip.shape),
steps: this.parseManeuvers(trip.legs[0].maneuvers),
confidence: 0.95,
};
return [route];
}
parseManeuvers(maneuvers) {
return maneuvers.map(maneuver => ({
instruction: maneuver.instruction,
distance: Math.round(maneuver.length * 1000),
time: maneuver.time,
type: maneuver.type?.toString() || 'unknown',
geometry: [],
}));
}
decodePolyline(encoded) {
const points = [];
let index = 0;
let lat = 0;
let lng = 0;
while (index < encoded.length) {
let result = 1;
let shift = 0;
let b;
do {
b = encoded.charCodeAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lat += (result & 1) !== 0 ? ~(result >> 1) : (result >> 1);
result = 1;
shift = 0;
do {
b = encoded.charCodeAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lng += (result & 1) !== 0 ? ~(result >> 1) : (result >> 1);
points.push({
lat: lat / 1e5,
lng: lng / 1e5,
});
}
return points;
}
estimateFuelCost(distanceKm, costing) {
if (costing !== 'auto')
return 0;
const fuelEfficiency = 10;
const fuelPricePerLiter = 1.5;
return Math.round((distanceKm / fuelEfficiency) * fuelPricePerLiter * 100) / 100;
}
generateRequestId() {
return `route_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
}
async getServiceStatus() {
try {
const response = await this.valhallaClient.get('/status');
return {
status: 'healthy',
version: response.data?.version,
};
}
catch (error) {
this.logger.error('Valhalla service health check failed', error);
return {
status: 'unhealthy',
};
}
}
};
exports.RoutingService = RoutingService;
exports.RoutingService = RoutingService = RoutingService_1 = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [config_1.ConfigService])
], RoutingService);
//# sourceMappingURL=routing.service.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
import { ParkingHistory } from '../../parking/entities/parking-history.entity';
export declare class User {
id: string;
email: string;
name: string;
password: string;
preferences: Record<string, any>;
isActive: boolean;
createdAt: Date;
parkingHistory: ParkingHistory[];
toJSON(): Omit<this, "password" | "toJSON">;
}

View File

@@ -0,0 +1,65 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = void 0;
const typeorm_1 = require("typeorm");
const swagger_1 = require("@nestjs/swagger");
const parking_history_entity_1 = require("../../parking/entities/parking-history.entity");
let User = class User {
toJSON() {
const { password, ...result } = this;
return result;
}
};
exports.User = User;
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Unique identifier for the user' }),
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
__metadata("design:type", String)
], User.prototype, "id", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'User email address' }),
(0, typeorm_1.Column)({ type: 'varchar', length: 255, unique: true, nullable: true }),
__metadata("design:type", String)
], User.prototype, "email", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'User full name' }),
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
__metadata("design:type", String)
], User.prototype, "name", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Hashed password' }),
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
__metadata("design:type", String)
], User.prototype, "password", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'User preferences and settings' }),
(0, typeorm_1.Column)({ type: 'jsonb', default: '{}' }),
__metadata("design:type", Object)
], User.prototype, "preferences", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'Whether the user account is active' }),
(0, typeorm_1.Column)({ type: 'boolean', default: true }),
__metadata("design:type", Boolean)
], User.prototype, "isActive", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'User creation timestamp' }),
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], User.prototype, "createdAt", void 0);
__decorate([
(0, typeorm_1.OneToMany)(() => parking_history_entity_1.ParkingHistory, (history) => history.user),
__metadata("design:type", Array)
], User.prototype, "parkingHistory", void 0);
exports.User = User = __decorate([
(0, typeorm_1.Entity)('users')
], User);
//# sourceMappingURL=user.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../../src/modules/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AACjB,6CAA8C;AAC9C,0FAA+E;AAGxE,IAAM,IAAI,GAAV,MAAM,IAAI;IAkCf,MAAM;QACJ,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;QACrC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,C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,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;;4CAC1B;eA/BtB,IAAI;IADhB,IAAA,gBAAM,EAAC,OAAO,CAAC;GACH,IAAI,CAsChB"}

View File

@@ -0,0 +1,7 @@
import { UsersService } from './users.service';
import { User } from './entities/user.entity';
export declare class UsersController {
private readonly usersService;
constructor(usersService: UsersService);
findAll(): Promise<User[]>;
}

View File

@@ -0,0 +1,39 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UsersController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const users_service_1 = require("./users.service");
const user_entity_1 = require("./entities/user.entity");
let UsersController = class UsersController {
constructor(usersService) {
this.usersService = usersService;
}
async findAll() {
return this.usersService.findAll();
}
};
exports.UsersController = UsersController;
__decorate([
(0, common_1.Get)(),
(0, swagger_1.ApiOperation)({ summary: 'Get all users' }),
(0, swagger_1.ApiResponse)({ status: 200, description: 'Successfully retrieved users', type: user_entity_1.User, isArray: true }),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], UsersController.prototype, "findAll", null);
exports.UsersController = UsersController = __decorate([
(0, swagger_1.ApiTags)('Users'),
(0, common_1.Controller)('users'),
__metadata("design:paramtypes", [users_service_1.UsersService])
], UsersController);
//# sourceMappingURL=users.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../../src/modules/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,6CAAqE;AACrE,mDAA+C;AAC/C,wDAA8C;AAIvC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAKrD,AAAN,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;CACF,CAAA;AATY,0CAAe;AAMpB;IAHL,IAAA,YAAG,GAAE;IACL,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;IAC1C,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,8BAA8B,EAAE,IAAI,EAAE,kBAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;;;8CAGpG;0BARU,eAAe;IAF3B,IAAA,iBAAO,EAAC,OAAO,CAAC;IAChB,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAEyB,4BAAY;GAD5C,eAAe,CAS3B"}

View File

@@ -0,0 +1,2 @@
export declare class UsersModule {
}

View File

@@ -0,0 +1,26 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UsersModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const users_controller_1 = require("./users.controller");
const users_service_1 = require("./users.service");
const user_entity_1 = require("./entities/user.entity");
let UsersModule = class UsersModule {
};
exports.UsersModule = UsersModule;
exports.UsersModule = UsersModule = __decorate([
(0, common_1.Module)({
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User])],
controllers: [users_controller_1.UsersController],
providers: [users_service_1.UsersService],
exports: [users_service_1.UsersService],
})
], UsersModule);
//# sourceMappingURL=users.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"users.module.js","sourceRoot":"","sources":["../../../src/modules/users/users.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,yDAAqD;AACrD,mDAA+C;AAC/C,wDAA8C;AAQvC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IANvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,CAAC,CAAC,CAAC;QAC3C,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}

View File

@@ -0,0 +1,12 @@
import { Repository } from 'typeorm';
import { User } from './entities/user.entity';
export declare class UsersService {
private readonly userRepository;
constructor(userRepository: Repository<User>);
findAll(): Promise<User[]>;
findById(id: string): Promise<User | null>;
findByEmail(email: string): Promise<User | null>;
create(userData: Partial<User>): Promise<User>;
update(id: string, userData: Partial<User>): Promise<User>;
delete(id: string): Promise<void>;
}

View File

@@ -0,0 +1,51 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UsersService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const typeorm_2 = require("typeorm");
const user_entity_1 = require("./entities/user.entity");
let UsersService = class UsersService {
constructor(userRepository) {
this.userRepository = userRepository;
}
async findAll() {
return this.userRepository.find();
}
async findById(id) {
return this.userRepository.findOne({ where: { id } });
}
async findByEmail(email) {
return this.userRepository.findOne({ where: { email } });
}
async create(userData) {
const user = this.userRepository.create(userData);
return this.userRepository.save(user);
}
async update(id, userData) {
await this.userRepository.update(id, userData);
return this.findById(id);
}
async delete(id) {
await this.userRepository.delete(id);
}
};
exports.UsersService = UsersService;
exports.UsersService = UsersService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
__metadata("design:paramtypes", [typeorm_2.Repository])
], UsersService);
//# sourceMappingURL=users.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../../src/modules/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AACrC,wDAA8C;AAGvC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAEmB,cAAgC;QAAhC,mBAAc,GAAd,cAAc,CAAkB;IAChD,CAAC;IAEJ,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAuB;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,QAAuB;QAC9C,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;CACF,CAAA;AA/BY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qCACU,oBAAU;GAHlC,YAAY,CA+BxB"}

1
backend/dist/tsconfig.tsbuildinfo vendored Normal file

File diff suppressed because one or more lines are too long

1
backend/node_modules/.bin/acorn generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../acorn/bin/acorn

1
backend/node_modules/.bin/browserslist generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../browserslist/cli.js

1
backend/node_modules/.bin/create-jest generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../create-jest/bin/create-jest.js

1
backend/node_modules/.bin/ejs generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../ejs/bin/cli.js

1
backend/node_modules/.bin/eslint generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../eslint/bin/eslint.js

1
backend/node_modules/.bin/eslint-config-prettier generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../eslint-config-prettier/bin/cli.js

1
backend/node_modules/.bin/esparse generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../esprima/bin/esparse.js

Some files were not shown because too many files have changed in this diff Show More