- API application to analyze the sentiment of text in request.
- Use TypeScript
- Use Nest.js
- Set up Swagger UI
- Use Google Cloud Natural Language API
analyzeSentiment
(More info: https://cloud.google.com/natural-language/docs/analyzing-sentiment#language-sentiment-string-protocol) - Response should contain score and magnitude.
- DB storage of results.
- Useful logging.
- Basic unit and end to end testing.
- Dockerize solution, if time.
- Push solution to github or email a zip file.
- If you run out of time, please be prepared to explain what you would have done with more time.
- Set up DB to store and memoize results. Check db before hitting GCP to limit requests to new text strings.
- Dockerize solution.
- Set up CI/CD for deployment to staging and production.
- Set up env vars for staging, production.
- Set up logger to log errors to Sentry, DataDog or something similiar.
- Create a health check to replace the hello world endpoint and create alert on cloud if api is down.
- Test that a duplicate request with exact same string does not call GCP.
- Limit text input to GCP's limit or smaller and create unit test.
- Remove special characters from user's input string and create test for this.
Nest framework TypeScript starter repository.
- Make sure you are using node version 18+.
- Rename .example.env to .env and fill in key value. Key value can be created by going to https://console.cloud.google.com/apis/credentials once you have account set up.
$ yarn
# development
$ yarn start
# watch mode
$ yarn start:dev
# production mode
$ yarn run start:prod
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov