This is a node.js app that depends on the following technologies.
Express.js: A Fast, opinionated, minimalist web framework for node which was used in routing this application.
BodyParser: This module was used to collect search data sent from the client side to the routing page.
Sequelize: Sequelize is a promise-based Node.js ORM for Postgres Server which is the database server for the app. It features solid transaction support, relations, read replication and more.
Postgresql: PostgreSQL is a powerful, open source object-relational database system.
- Install (if not installed)
- nodejs
- postgresql
- sequelize-cli (install this globally)
- Navigate to the directory you want it installed to. cd your folder
- Clone the repository
https://github.com/HawiCaesar/sms-management-api.git
. - Create 2 databases(test and development) with PostgreSQL.
- Open the sms-management-api folder.
- Create a .env file using the .env.example as a guide.
npm install
to install all dependencies.sequelize db:migrate
to run migrations.npm start
to start the app in development mode.npm test
runs all the tests.- The app runs on port 8000
- A user can create contact
- A user can get all contacts
- A user can get a single contact
- A user can update a contact
- A user can delete a contact
- A user can create a message
- A user can get messages sent by a contact
- A user can get messages received by a contact
- A user can delete a message
{
"name": "James Dun",
"phone": "254789123450",
}
{
"message": "contact created",
"contact": {
"id": 7,
"name": "Marvin Yel",
"phone": "254789123450",
"updatedAt": "2019-03-26T19:26:12.707Z",
"createdAt": "2019-03-26T19:26:12.707Z"
}
}
{
"contacts": [
{
"id": 2,
"name": "Orlod FRed",
"phone": "254790123000",
"createdAt": "2019-03-26T13:26:04.216Z",
"updatedAt": "2019-03-26T13:26:04.216Z"
},
{
"id": 3,
"name": "Greg Frodo",
"phone": "254769123350",
"createdAt": "2019-03-26T13:29:49.699Z",
"updatedAt": "2019-03-26T13:29:49.699Z"
},
{
"id": 7,
"name": "Marvin Yel",
"phone": "254789123450",
"createdAt": "2019-03-26T19:26:12.707Z",
"updatedAt": "2019-03-26T19:26:12.707Z"
}
]
}
{
"message": "Contact retrived",
"contact": {
"id": 3,
"name": "Greg Frodo",
"phone": "1239009321",
"createdAt": "2019-03-26T13:29:49.699Z",
"updatedAt": "2019-03-26T13:29:49.699Z",
"sentMessages": [
{
"id": 10,
"senderId": 3,
"receiverId": 2,
"message": "Captain Marvel ?",
"status": "sent",
"createdAt": "2019-03-26T13:52:04.284Z",
"updatedAt": "2019-03-26T13:52:04.284Z"
},
{
"id": 11,
"senderId": 3,
"receiverId": 2,
"message": "Vroom",
"status": "sent",
"createdAt": "2019-03-26T13:52:09.105Z",
"updatedAt": "2019-03-26T13:52:09.105Z"
},
{
"id": 12,
"senderId": 3,
"receiverId": 2,
"message": "ChuChu",
"status": "sent",
"createdAt": "2019-03-26T13:52:23.615Z",
"updatedAt": "2019-03-26T13:52:23.615Z"
},
{
"id": 13,
"senderId": 3,
"receiverId": 2,
"message": "Get a move on",
"status": "sent",
"createdAt": "2019-03-26T13:52:30.156Z",
"updatedAt": "2019-03-26T13:52:30.156Z"
}
],
"receivedMessages": [
{
"id": 14,
"senderId": 2,
"receiverId": 3,
"message": "I am gracious enough",
"status": "sent",
"createdAt": "2019-03-26T16:33:16.555Z",
"updatedAt": "2019-03-26T16:33:16.555Z"
}
]
}
}
{"name": "Marvin Yellow", phone: "254789123450"}
{
"message": "Contact updated",
"contact": {
"id": 7,
"name": "Marvin Yellow",
"phone": "254789123450",
"createdAt": "2019-03-26T19:26:12.707Z",
"updatedAt": "2019-03-26T19:48:49.437Z"
}
}
status code 204
{ "sender": "254789123450", "receiver": "1239009321", "message": "goody"}
{
"response": {
"id": 15,
"senderId": 7,
"receiverId": 3,
"message": "goody",
"status": "sent",
"updatedAt": "2019-03-26T19:53:05.458Z",
"createdAt": "2019-03-26T19:53:05.458Z"
}
}
status code 204
in this case phone is 1239009321
{
"contact": {
"name": "Greg Frodo",
"phone": "1239009321"
},
"sentMessages": [
{
"id": 10,
"senderId": 3,
"receiverId": 2,
"message": "Captain Marvel ?",
"status": "sent",
"createdAt": "2019-03-26T13:52:04.284Z",
"updatedAt": "2019-03-26T13:52:04.284Z"
},
{
"id": 11,
"senderId": 3,
"receiverId": 2,
"message": "Vroom",
"status": "sent",
"createdAt": "2019-03-26T13:52:09.105Z",
"updatedAt": "2019-03-26T13:52:09.105Z"
},
{
"id": 12,
"senderId": 3,
"receiverId": 2,
"message": "ChuChu",
"status": "sent",
"createdAt": "2019-03-26T13:52:23.615Z",
"updatedAt": "2019-03-26T13:52:23.615Z"
},
{
"id": 13,
"senderId": 3,
"receiverId": 2,
"message": "Goody",
"status": "sent",
"createdAt": "2019-03-26T13:52:30.156Z",
"updatedAt": "2019-03-26T13:52:30.156Z"
}
]
}
in this case phone is 1239009321
{
"contact": {
"name": "Greg Frodo",
"phone": "1239009321"
},
"receivedMessages": [
{
"id": 14,
"senderId": 2,
"receiverId": 3,
"message": "I am gracious enough",
"status": "sent",
"createdAt": "2019-03-26T16:33:16.555Z",
"updatedAt": "2019-03-26T16:33:16.555Z"
}
]
}