Defining routes

Now that we have the required dependencies, we will update the routes. To work with Translation API, we are going to add two routes. One will return the list of supported languages and the other will translate text. Update server\routes\cloud-ai-api.ts and add the supported-languages and translate-message routes as shown here:

// SNIPP SNIPProuter.get('/supported-languages', Authenticate, Authorize('user'), cloudAIAPI.getSupportedLanguages);router.post('/translate-message', Authenticate, Authorize('user'), cloudAIAPI.translateMessage);// SNIPP SNIPP

Get Google Cloud AI Services Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.