Giter Site home page Giter Site logo

smsapi / smsapi-javascript-client Goto Github PK

View Code? Open in Web Editor NEW
27.0 27.0 10.0 1.58 MB

SMSAPI javascripts client that allows you to send messages and administrate your SMSAPI account.

Home Page: https://www.smsapi.com/

License: Apache License 2.0

JavaScript 0.18% Makefile 0.72% TypeScript 99.10%

smsapi-javascript-client's People

Contributors

adrian-olczyk avatar dependabot[bot] avatar pdziewa avatar tymekpudlik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

smsapi-javascript-client's Issues

Please provide typescript .d.ts typings

Please provide a typescript .d.ts typings for the library. Typescript is gaining popularity very quickly, and it is a great solution for critical apps as it prevents many mistakes at a very early stage of development. SMS sending is indeed a critical part of an app as it has both money and direct user experience involved. Thanks!

Please provide Changelog

Please provide a changelog so that one could determine what kind of changes are released with new versions.

Are there any breaking API changes with the 2.0 release?

(You may consider using semantic-release to manage versioning)

axios library upgrade

                       === npm audit security report ===                        
                                                                                
┌──────────────────────────────────────────────────────────────────────────────┐
│                                Manual Review                                 │
│            Some vulnerabilities require your attention to resolve            │
│                                                                              │
│         Visit https://go.npm.me/audit-guide for additional guidance          │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Server-Side Request Forgery                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ axios                                                        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=0.21.1                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ smsapi                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ smsapi > axios                                               │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/1594                            │
└───────────────┴──────────────────────────────────────────────────────────────┘

No parser and no filepath given, using 'babel' the parser now but this will throw an error in the future.

The error using this module in nodejs v12.13.0

No parser and no filepath given, using 'babel' the parser now but this will throw an error in the future.

implementation:

import { Injectable } from '@nestjs/common';
import {configService} from "../../shared/config/config.service";

const SMSAPI = require('smsapi');

@Injectable()
export class SmsService {

private smsFrom: string;
private smsapi: any;

constructor() {
    this.smsFrom = configService.getValue('SMS_FROM');

    this.smsapi = new SMSAPI({
        oauth: {
            accessToken: configService.getValue('SMS_ACCESS_TOKEN')
        }
    });
}

public sendMessage(to: string, body: string): Promise<any> {
    return this.smsapi.message
        .sms()
        .from(this.smsFrom)
        .to(to)
        .message(body)
        .execute();
}

}

everything works fine when commenting smsapi related logic (leaving tbh empty sendMessage and config related things)

ps. sorry for bad formatting, cant work it out to work with nestjs annotations

Can't really use ProxyAbstract

As I understand, ProxyAbstract is exposed by smsapi.js, in order to provide a method for implementing a custom class, that has a request method, which returns an instance of lib/Request.

My issue is that lib/Request is not exposed on lib/smsapi, so I can't really return an instance of this private library class.

SMSAPI is not a constructor

importing the library in nestjs (express, typescript) ends with error: SMSAPI is not a constructor
tried all possible versions from 1.0 to 2.0.11.
node: v.16.15.1

code:

import { Controller, Get } from '@nestjs/common';
import { SMSAPI } from 'smsapi';

@Controller('sms')
export class SmsController {



    @Get()
    async testSms() {

        const smsapi = new SMSAPI('Bxxxxxxxxxxxxxxxxxxxxxxxxxi');

        try {
            const result = smsapi.sms.sendSms('+486xxxxxxxxx', 'My first message!');

            console.log(result);
        } catch (err) {
            console.log(err);

        }
    }
}

error:

express-server | [Nest] 842   - 11/29/2023, 8:23:20 AM   [ExceptionsHandler] smsapi_1.SMSAPI is not a constructor +52636550ms
express-server | TypeError: smsapi_1.SMSAPI is not a constructor
express-server |     at SmsController.test2 (/usr/src/app/dist/src/sms/sms.controller.js:17:24)
express-server |     at /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:38:29
express-server |     at InterceptorsConsumer.intercept (/usr/src/app/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:11:20)
express-server |     at /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:46:60
express-server |     at /usr/src/app/node_modules/@nestjs/core/router/router-proxy.js:9:23
express-server |     at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
express-server |     at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)
express-server |     at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)
express-server |     at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
express-server |     at /usr/src/app/node_modules/express/lib/router/index.js:281:22

Setting boolean options as `false` sets them as `true`

Example:

smsapi.message.sms()
    .from('Info')
    .to('501501501')
    .message('My message')
    .normalize(false)
    .execute()

Calling .normalize(false) will actually result in setting the normalize option to true. I presume this is because it is probably sent to the server as normalize=false which is not normalize=0 and therefore is interpreted as setting the option.

The use case:

var message = 'Pewna wiadomość'
return smsapi.message.sms()
    .from('Info')
    .to('501501501')
    .message(message)
    .normalize(message.length > 70)
    .execute()

Temporary fix: coercing to number like this: .normalize(+(message.length > 70)).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.