This project demonstrates how to set up a TypeScript application that:
- Uses external libraries
- Implements environment variables configuration with Webpack
- Shows best practices for TypeScript project structure
- TypeScript configuration and setup
- Webpack integration for environment variables management
- External library integration example
- Development environment configuration with Webpack Dev Server
This project requires a Google Maps API key to function. Follow these steps:
-
Get a Google Maps API Key:
-
Visit Google Maps Platform
-
Create or select a project
-
Enable at least the following APIs:
- Directions API
- Maps Embed API
- Geolocation API
- Maps JavaScript API
- Geocoding API
- Maps Elevation API
- Maps Static API
-
Create credentials (API key)
-
-
Set up your API key:
- Create a
.env
file in the root directory - Add your API key:
GOOGLE_MAPS_API_KEY=your_api_key_here
- Create a
⚠️ Security Note:
The current implementation exposes the API key in the client-side code. For production environments, it's strongly recommended to implement a backend proxy:
- Instead of making direct API calls from the frontend, route requests through your backend server
- Keep the API key secure on the backend
- Your backend acts as an intermediary, making the actual calls to Google Maps API
- This prevents exposure of your API key in client-side code
This proxy pattern provides better security for your API credentials in production environments.
-
Clone this repository:
git clone https://github.com/juanmaguitar/typescript-demo.git cd typescript-demo
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Build the project:
npm run build