Skip to content

Instantly share code, notes, and snippets.

// 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
}
// Firstly, we setup Database Connection
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'postgres',
database: 'postgres',
import { IsString, IsInt } from 'class-validator';
export class CreateCatDto {
@IsString()
name: string;
@Length(10)
description: string;
}
@cacheManagerDecorator()
async getHello() {
return `Hello - ${new Date().toLocaleString()}`;
}
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');
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;
}
{
"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,
{
"$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"
},
// Register LUIS recognizer
services.AddSingleton<AppointmentBookingRecognizer>();
// Register the AppointmentBookingDialog
services.AddSingleton<AppointmentBookingDialog>();
// The MainDialog that will be run by the bot.
services.AddSingleton<MainDialog>();
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")]