Created
March 30, 2020 16:47
-
-
Save edolix/9661d9233a6dbab009da32a5e79d34af to your computer and use it in GitHub Desktop.
@signalwire/node NestJS integration
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 { Controller, Get } from '@nestjs/common'; | |
const { RestClient } = require('@signalwire/node'); | |
const project = '<SPACE-PROJECT>'; | |
const token = '<SPACE-TOKEN>'; | |
const spaceUrl = 'example.signalwire.com'; | |
const restClient = RestClient(project, token, { signalwireSpaceUrl: spaceUrl }); | |
@Controller() | |
export class AppController { | |
@Get() | |
getHello(): Promise<string> { | |
var response = new RestClient.LaML.VoiceResponse(); | |
response.say('Hello World!'); | |
return response.toString(); | |
} | |
@Get('calls') | |
async getCallCounter(): Promise<string> { | |
const list = await restClient.calls.list(); | |
return `You have ${list.length} calls.`; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment