
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
loopback-connector-seven
Advanced tools
The official seven connector for LoopBack. Prior to using you will need to create an API key.
This connector supports the following endpoints of the seven REST API:
In your LoopBack project:
$ npm i loopback-connector-seven
$ yarn add loopback-connector-seven
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core'
import {juggler} from '@loopback/repository'
import {SevenConnector} from 'loopback-connector-seven'
const config = {
apiKey: process.env.SMS77_DUMMY_API_KEY,
connector: SevenConnector,
name: 'seven',
}
@lifeCycleObserver('datasource')
export class SevenDataSource extends juggler.DataSource implements LifeCycleObserver {
static dataSourceName = 'seven'
static readonly defaultConfig = config
constructor(
@inject('datasources.config.seven', {optional: true})
dsConfig: object = config,
) {
super('seven', dsConfig)
}
}
import {Model, model, property} from '@loopback/repository';
@model()
export class SevenMessage extends Model {
@property({
generated: false,
id: true,
required: true,
type: 'string',
})
operation: 'voice' | 'sms';
@property({
required: true,
type: 'string',
})
to: string;
@property({
required: false,
type: 'string',
})
from: string;
@property({
required: true,
type: 'string',
})
text: string;
constructor(data?: Partial<SevenMessage>) {
super(data);
}
}
export interface SevenRelations {
// describe navigational properties here
}
export type SevenWithRelations = SevenMessage & SevenRelations;
import {injectable, BindingScope, Provider, inject} from '@loopback/core'
import {GenericService, getService} from '@loopback/service-proxy'
import {SevenDataSource} from '../datasources'
import {SevenMessage} from '../models'
export interface Seven extends GenericService {
send(data: SevenMessage): Promise<unknown>;
}
@injectable({scope: BindingScope.TRANSIENT})
export class SevenProvider implements Provider<Seven> {
constructor(
@inject('datasources.seven')
protected dataSource: SevenDataSource = new SevenDataSource(),
) {
}
value(): Promise<Seven> {
return getService(this.dataSource)
}
}
import {inject} from '@loopback/core'
import {post} from '@loopback/rest'
import {SevenMessage} from '../models'
import {Seven} from '../services'
export class SmsController {
@post('/send-sms')
async sms(
@inject('services.Seven') sevenProvider: Seven,
): Promise<void> {
const msg = new SevenMessage({
from: 'optional sender ID',
operation: 'sms',
text: 'This is a test SMS from LoopBack via seven',
to: 'phone number(s) for calling separated by comma',
})
try {
const json = await sevenProvider.send(msg)
console.log('json', json)
} catch (e) {
console.error('e', e)
throw e
}
}
}
import {inject} from '@loopback/core'
import {post} from '@loopback/rest'
import {SevenMessage} from '../models'
import {Seven} from '../services'
export class TextToSpeechController {
@post('/send-voice')
async voice(
@inject('services.Seven') sevenProvider: Seven,
): Promise<void> {
const msg = new SevenMessage({
from: 'optional caller ID',
operation: 'voice',
text: 'This is a test call from LoopBack via seven',
to: 'the number for calling',
})
try {
const json = await sevenProvider.send(msg)
console.log('json', json)
} catch (e) {
console.error('e', e)
throw e
}
}
}
{
from: 'OPTIONAL_SENDER_ID',
operation: 'sms',
text: 'TEXT_MESSAGE',
to: 'TARGET_PHONE_NUMBER(S)'
}
{
from: 'OPTIONAL_CALLER_ID',
operation: 'call',
text: 'TEXT_OR_XML',
to: 'TARGET_PHONE_NUMBER'
}
Need help? Feel free to contact us.
FAQs
LoopBack connector for seven
We found that loopback-connector-seven demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.