81 lines
1.8 KiB
Markdown
81 lines
1.8 KiB
Markdown
# Serverless TypeScript Project
|
|
|
|
This folder contains AWS Lambda functions deployed via the Serverless Framework, written in TypeScript.
|
|
|
|
## Setup
|
|
|
|
This project is configured with TypeScript, ESLint, and Prettier independently from the main project.
|
|
|
|
### Prerequisites
|
|
|
|
- Node.js 22.x or higher
|
|
- npm or yarn
|
|
|
|
### Installation
|
|
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
## Development
|
|
|
|
### Available Scripts
|
|
|
|
- `npm run build` - Compile TypeScript to JavaScript
|
|
- `npm run type-check` - Run TypeScript type checking without emitting files
|
|
- `npm run lint` - Run ESLint on TypeScript files
|
|
- `npm run lint:fix` - Run ESLint with auto-fix
|
|
- `npm run format` - Format code with Prettier
|
|
- `npm run format:check` - Check if code is formatted correctly
|
|
|
|
### Project Structure
|
|
|
|
```
|
|
src/
|
|
handlers/ # Lambda function handlers
|
|
vehicleType.ts # Vehicle type lookup handler
|
|
scrub.ts # Estimate scrubbing handler
|
|
emsupload.ts # File upload presigned URL handler
|
|
lib/ # Shared library code
|
|
vehicleTypes/ # Vehicle type utilities
|
|
db.ts # Database utilities
|
|
```
|
|
|
|
## Deployment
|
|
|
|
The project uses `serverless-esbuild` for bundling TypeScript code for deployment.
|
|
|
|
```bash
|
|
# Deploy to dev stage
|
|
sls deploy --stage dev
|
|
|
|
# Deploy to production
|
|
sls deploy --stage prod
|
|
```
|
|
|
|
## Local Development
|
|
|
|
```bash
|
|
# Run serverless offline
|
|
sls dev
|
|
```
|
|
|
|
## Configuration
|
|
|
|
- **TypeScript**: Configured in `tsconfig.json`
|
|
- **ESLint**: Configured in `eslint.config.mjs` (ESM flat config)
|
|
- **Prettier**: Configured in `.prettierrc.json`
|
|
- **Serverless**: Configured in `serverless.yml`
|
|
|
|
## Code Quality
|
|
|
|
This project enforces:
|
|
- TypeScript strict mode
|
|
- ESLint rules for TypeScript
|
|
- Prettier formatting
|
|
- No unused variables or parameters (except those prefixed with `_`)
|
|
|
|
## Environment Variables
|
|
|
|
See `serverless.yml` for environment-specific configuration.
|