Simple Angular app to test Amazon Translate service
This project has 2 folders:
- angular-ui: containing the project user interface in Angular 16
- aws-lambda-api: containing service lambda functions
You'll need to have AWS account and AWS SAM CLI + npm + Angular CLI installed.
Make sure you're in the api folder and run sam build.
sam build
sam local invoke -e ./events/languages-event.json FetchLanguagesFunction
Make sure you're in the api folder and run sam build.
sam local invoke -e ./events/translate-event.json TranslateTextFunction
Open a new terminal and browse to the api folder. Then start the local api gateway.
sam local start-api
Your local api gateway should responding at http://localhost:3000
In another terminal, run:
curl http://localhost:3000/languages
In another terminal, run:
curl -X POST http://localhost:3000/translate -H 'Content-Type: application/json' -d '{"source":"en","target":"de","text": "Hello World!"}'
sam package
sam deploy
Once the stack deployment is over, retrieve and copy the api gateway URL, which you'll later on pass to the UI app. It will have this format: "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com". The value you'll be providing to the UI will look like: "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod", where Prod is the deployment stage. Example: https://gefoihfahbbfbf.execute-api.us-east-1.amazonaws.com/Prod
Browse to folder angular-ui.
Edit all environment files located in src/environments. Replace the attribute apiUrl with the appropriate value (ex. https://gefoihfahbbfbf.execute-api.us-east-1.amazonaws.com/Prod).
Run npm install if necessary.
npm install
Run:
ng serve
Then go to http://localhost:4200 to view the app
ng build -c production
That's up to you. You can either use an Amazon S3 bucket, or an Apache Web Server or an nginx Web server to deploy the content of app located in folder dist