Node, Express, PostreSQL RESTful API
Manage the details of your contacts.View, add, update and delete your contacts details such as name, phone numbers and location.
- Node v6.10.0
- Express v4.15.3
- PostgreSQL v9.6
- Sequelize v4.2.1 as ORM
Download or clone the repostisory
git clone https://github.com/Pierre-D-G/Contacts-API.git
cd Contacts API/
Run npm install to install dependanciesRun npm run dev to run the development server
runs
nodemonto automatically restart the server when a change is made
Create a file named config.js in the root of the project folder with the structure:
module.exports = {
database: //'named of development database',
username: //'database login username',
password: //'database login password'
}Run npm test to execute unit tests via Mocha and Chai
Tests the API endpoints to make sure the correct responses are being sent when requests are made
Testing Get all contacts
GET /api/contacts - retrieves all contacts
describe('Get all contacts', () => {
it('it should GET all contacts', (done) => {
chai.request(server)
.get('/api/contacts')
.end((err, res) => {
res.should.have.status(200);
res.body.should.be.a('array');
done();
})
})
});- GET -
/api/contacts- view all your contacts and a few details about them - GET -
/api/contacts/:id- view all the details about a contact - POST -
/api/contacts- Create a new contact - PUT -
/api/contacts/:id- Update a contact's details - DELETE -
/api/contacts/:id- Delete a contact
-
Create Routes
- Get -
/api/contacts- view all your contacts and a few details about them - Get -
/api/contacts/:id- view all the details about a contact - Post -
/api/contacts- Create a new contact - Put -
/api/contacts/:id- Update a contact's details - Delete -
/api/contacts/:id- Delete a contact
- Get -
-
Create Route Tests
Get -/api/contacts- view all your contacts and a few details about themGet -/api/contacts/:id- view all the details about a contactPost -/api/contacts- Create a new contactPut -/api/contacts/:id- Update a contact's detailsDelete -/api/contacts/:id- Delete a contact
MIT