This API creates an SMS Management API using Node.js.
The SMS Management system helps to send messages to a contact. Also, ensures the right contact gets the message.
The project structure follows the MVC (Model-View-Controller) pattern. You can think of the JSON representation of data returned by the API as the 'view'.
├── src/
├── bin
│ └── www.js
├── controllers
│ └── ContactController.js
├── helpers
│ └── validationErrorHandler.js
├── middlewares
│ └── verifyUserInputs.js
├── models
│ └── Contact.js
├── repositories
│ └── BaseRepository.js
├── routes
│ └── index.js
├── app.js
- Node.js v10.x or higher
- npm
- MongoDB instance (local or remote)
$ git clone https://github.com/jherey/sms_management.git
$ cd sms_management
$ npm install
$ npm dev # For development purpose
$ npm start # To run production build
You should now be able to access the API via http://localhost:4500/api/
NOTE: Create a .env
file configuration following the .env.example
.
SMS:
- person sending sms
- person receiving sms
- message of sms
- sms status
Contact:
- name of person
- phone number of person
The following relationships are represented in the model:
- All sms sent by a Contact are linked to them
- All sms sent to a Contact are linked to them
- Deleting a contact removes the messages they sent and references to messages they received.
HTTP VERB | ENDPOINTS | DESCRIPTION |
---|---|---|
POST | /api/contacts | Creates a contact |
GET | /api/contacts | Gets all contact |
POST | /api/sms/:contactId | Sends sms to a contact |
GET | /api/sms | Gets all sms |
GET | /api/sms/sent/:contactId | Gets all contact's sent sms |
GET | /api/sms/received/:contactId | Gets all contact's received sms |
DELETE | /api/contacts/:contactId | Delete a contact |