Nest framework TypeScript starter repository.
$ npm install
$ export NODE_ENV=dev
SmartCar.CLIENT_ID="[...]"
SmartCar.CLIENT_SECRET="[...]"
SmartCar.REDIRECT_URL="https://....ngrok.io/smartcar/exchange"
SmartCar.TestMode=true
AWS.Region="us-west-1"
This config is used by config.service.ts
and loaded in config.module.ts
Table | Hash Key | Sort Key | Notes |
---|---|---|---|
odo-vehicle |
vehicleId (string) |
N/A | see vehicle.entity.ts for details |
odo-odometerHistory |
vehicleId (string) |
date (number) |
see odometer-history.entity.ts for details |
Smart Car SDK requires client id, client secret, and redirect url for callbacks. These can be obtained from Smart Car dashboard when creating an application.
For debuging purposes, use ngrok to open access for Smart Car backend to your local web server.
This package relies on AWS CLI credentials stored in the profile
$ cat ~/.aws/credentials
Named Profiles are supported in .env
configuration file with option
AWS.Profile = profile_name
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
- Run the app
- Open http://localhost:3000/smartcar/auth
- Follow prompts in SmartCar interface
- Redirected back to https://xxxxxx.ngrok.io/smartcar/exchange?code=xxxxxxxxxx
- Check vehicle linked http://localhost:3000/debug/vehicles
- Run the batch http://localhost:3000/smartcar/updateBatch
400 Unauthorized redirect_uri: https://xxxxxxx.ngrok.io/smartcar/exchange
Smart Car requires whitelisting redirect URL in the dashboard. Login to the Smart Car and enter redirect URL under Credentials menu. The URL needs to match SmartCar.REDIRECT_URL
in *.env
config file.
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov