Defining routes

Now that we have the required dependencies, we will add the routes. Inside the server\routes folder, create a file named cloud-ai-api.ts and update it as follows:

// SNIPP SNIPPimport * as express from 'express';import * as multer from 'multer';const UPLOAD_PATH = __dirname + '/../uploads';const upload = multer({ dest: `${UPLOAD_PATH}/` });import { Authenticate, Authorize } from '../auth';import VisionAPI from '../controllers/cloud-ai-api';export default function defineCloudAIAPIRoutes(app) {   const router = express.Router();   const visionAPI = new VisionAPI();   // Upload Single Images   router.post('/upload-image/:threadId', Authenticate, Authorize('user'), upload.single('image-reply'), visionAPI.uploadImage); // Apply the routes ...

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.