This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Firstly, we need a schema file to model the database | |
generator client { | |
provider = "prisma-client-js" | |
} | |
datasource db { | |
provider = "postgresql" | |
url = env("DATABASE_URL") // the DATABASE_URL is stored in .env file | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Firstly, we setup Database Connection | |
@Module({ | |
imports: [ | |
TypeOrmModule.forRoot({ | |
type: 'postgres', | |
host: 'localhost', | |
port: 5432, | |
username: 'postgres', | |
password: 'postgres', | |
database: 'postgres', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IsString, IsInt } from 'class-validator'; | |
export class CreateCatDto { | |
@IsString() | |
name: string; | |
@Length(10) | |
description: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@cacheManagerDecorator() | |
async getHello() { | |
return `Hello - ${new Date().toLocaleString()}`; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CACHE_MANAGER, Inject } from '@nestjs/common'; | |
export const cacheManagerDecorator = (ttl = 10) => { | |
const injectCache = Inject(CACHE_MANAGER); | |
return function ( | |
target: any, | |
_propertyName: string, | |
descriptor: PropertyDescriptor, | |
) { | |
injectCache(target, 'cache'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const value = await this.cacheManager.get('test-key'); | |
if (!value) { | |
const response = await this.getHello(); | |
this.cacheManager.set( | |
'test-key', | |
response, | |
{ ttl: 0 }, | |
); | |
return response; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"active": true, | |
"author": "N/A", | |
"author_email": "N/A", | |
"complete": true, | |
"deployer": "ZipDeploy", | |
"end_time": "2022-02-27T21:58:45.0863404Z", | |
"id": "b3c4cbb7a470479ebd7a2c6dd17bd70f", | |
"is_readonly": true, | |
"is_temp": false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"appId": { | |
"value": "[CLIENT_ID_FROM_MANAGED_IDENTITY]" | |
}, | |
"appType": { | |
"value": "UserAssignedMSI" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Register LUIS recognizer | |
services.AddSingleton<AppointmentBookingRecognizer>(); | |
// Register the AppointmentBookingDialog | |
services.AddSingleton<AppointmentBookingDialog>(); | |
// The MainDialog that will be run by the bot. | |
services.AddSingleton<MainDialog>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Bot.Builder; | |
using Microsoft.Bot.Builder.Adapters.Twilio; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace AppointmentBot.Controllers | |
{ | |
[Route("api/twilio")] |