Files
2022-02-13 06:31:11 +00:00

2.7 KiB

Send SMS

Simple API gateway to send SMS messages through Clickatell.

Description

Node.js project to utilise PayLid/IRAS registered API account from Clickatell. Exposes RESTful interface to send SMS messages.

Getting Started

Dependencies

  • designed to run on CentOS 6.10 & node.js v11.15.0
  • express.js framework
  • no database interface since recent pg-native will not compile on CentOS 6.10

Installing

  • git clone git@gitlab.com:paylidproductteam/sms-api.git
  • npm install

Executing program

  • To run API in development mode, please use "dev" script from package.json
  • Start by
npm run dev

Calling API

curl -X POST http://10.10.20.101:4100/v1/sms/send \
 -H 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc0FkbWluIjoidHJ1ZSIsImlhdCI6MTYzMDY3NTIxMH0.9aqqaT1h7k_JUqUT3cwOvB0RvK51sQuuQuw6-o-6ufc' \
 -H 'Content-Type: application/json' \
 -d '{"number":"16784574356","text":"test from SMS API"}'

Getting Message Delivery Status

curl -X POST http://10.10.20.101:4100/v1/sms/status \
 -H 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc0FkbWluIjoidHJ1ZSIsImlhdCI6MTYzMDY3NTIxMH0.9aqqaT1h7k_JUqUT3cwOvB0RvK51sQuuQuw6-o-6ufc' \
 -H 'Content-Type: application/json' \
 -d '{"apiMessageId":"c7bfb6061000c8805e2cde9a5bdc9139"}'

Run Under Supervisor

Append the following configuration to /etc/supervisord.conf

[program:sms_api]
command=/home/developer/oameye/sms-api/start.sh
directory=/home/developer/oameye/sms-api
process_name=%(program_name)s
numprocs=1
umask=022
priority=1
user=oameye
group=dev
autostart=true
autorestart=true
redirect_stderr=true
log_stdout=true
log_stderr=true
stdout_logfile=/var/log/supervisor/sms_api.log

Run on Windows

Download https://nssm.cc/release/nssm-2.24.zip and install into node directory.

Usage https://nssm.cc/usage

nssm install SmsApiService C:\AutoMedSys\sms-api\start.bat
nssm set SmsApiService AppDirectory C:\AutoMedSys\sms-api
nssm set SmsApiService DisplayName "SMS API Service"
nssm set SmsApiService Description "SMS RESTful API for Clickatell gateway"
nssm set SmsApiService Start SERVICE_AUTO_START
nssm set SmsApiService AppExit Default Restart
nssm set SmsApiService AppRestartDelay 0
nssm set SmsApiService AppStdout C:\AutoMedSys\sms-api\service.log
nssm set SmsApiService AppStderr C:\AutoMedSys\sms-api\service.log
nssm start SmsApiService

Authors

Contributors names and contact info

Anatolii Okhotnikov @acidumirae

Version History

  • 0.3
    • Windows service startup instruction
    • Make middleware optional
  • 0.2
  • 0.1
    • Initial commit with express.js API skeleton