Skip to content

Instantly share code, notes, and snippets.

@edolix
Created March 30, 2020 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edolix/9661d9233a6dbab009da32a5e79d34af to your computer and use it in GitHub Desktop.
Save edolix/9661d9233a6dbab009da32a5e79d34af to your computer and use it in GitHub Desktop.
@signalwire/node NestJS integration
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