Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

[TypeScript][Skill] Add manifest endpoint #3601

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SampleAction } from './dialogs/sampleAction';
import { SkillState } from './models/skillState';
import { BotServices } from './services/botServices';
import { IBotSettings } from './services/botSettings';
import { readFileSync, existsSync } from 'fs';

const cognitiveModels: Map<string, ICognitiveModelConfiguration> = new Map();
const cognitiveModelDictionary: { [key: string]: Object } = cognitiveModelsRaw.cognitiveModels;
Expand Down Expand Up @@ -179,3 +180,16 @@ server.get('/api/messages', async (req: restify.Request, res: restify.Response):
await bot.run(turnContext);
});
});

// Enable endpoint to reach any file inside the bot manifest's folder
server.get('/manifest/:file', (req: restify.Request, res: restify.Response): void => {
const manifestFilename: string = req.params.file;
const manifestFilePath: string = join(__dirname, 'manifest', manifestFilename);
if (!existsSync(manifestFilePath)) {
res.send(404);
return;
}

const manifest: Object = JSON.parse(readFileSync(manifestFilePath, 'UTF8'));
res.send(200, manifest);
});
14 changes: 14 additions & 0 deletions templates/typescript/samples/sample-skill/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SampleAction } from './dialogs/sampleAction';
import { SkillState } from './models/skillState';
import { BotServices } from './services/botServices';
import { IBotSettings } from './services/botSettings';
import { readFileSync, existsSync } from 'fs';

const cognitiveModels: Map<string, ICognitiveModelConfiguration> = new Map();
const cognitiveModelDictionary: { [key: string]: Object } = cognitiveModelsRaw.cognitiveModels;
Expand Down Expand Up @@ -179,3 +180,16 @@ server.get('/api/messages', async (req: restify.Request, res: restify.Response):
await bot.run(turnContext);
});
});

// Enable endpoint to reach any file inside the bot manifest's folder
server.get('/manifest/:file', (req: restify.Request, res: restify.Response): void => {
const manifestFilename: string = req.params.file;
const manifestFilePath: string = join(__dirname, 'manifest', manifestFilename);
if (!existsSync(manifestFilePath)) {
res.send(404);
return;
}

const manifest: Object = JSON.parse(readFileSync(manifestFilePath, 'UTF8'));
res.send(200, manifest);
});