A database to save the data of people that I've met. I've created this project because of my personal needs and also I wanted to learn backend. I tried to write the code as much as clean and understandable as I could. If you want to add features please feel free to do so.
I want to implement this to a terminal based program and also a webapp in the future.
You'll be able to save the data specified below using REST API and MongoDB.
- Name
- Where you've met
- Place (that they live)
- Contact
- Number
- social media accounts
- Website
- Birthdate
- Age
- Likes
- Dislikes
- Occupation
- Last Contact
- When shold I contact next
- Additional notes
- Tags
npm install
- You'll need to install MongoDB either locally or from the cloud. Once you get your connection string change
./startup/db.js
connection string to your MongoDB adress. - You'll need token in order to use REST API. Your private key comes from
process.env.rememberMe_jwtkey
so you want tosetenv process.env.rememberMe_jwtkey "whatever"
- To get your jwtKey write
node -e 'require("./token").createToken()'
to terminal. This token expires in 30 days.
- To get your jwtKey write
- Run
node index.js
and you are ready.- Server port starts at
3002
if undefined. You can define the port by usingprocess.env.port
environment.
- Server port starts at
You are going to need to set your jwt key header x-auth-token: yourjwtkey
in order to make requests.
Here are the example requests you can make.
http://localhost:3002/api/person/
http://localhost:3002/api/person/get/Mike
http://localhost:3002/api/person/60fabc01465fd12839091b25
http://localhost:3002/api/person/
{
"name": "Mike",
"metAt": "Wall Maria Cafe",
"place": "Üsküdar",
"contact": {
"phone": "12345",
"email": "[email protected]",
"socialmedia": {
"instagram": "mike123",
"youtube": "mike123",
"twitter": "mike123"
}
},
"birth": "10.05.1998",
"age": 22,
"likes": ["football", "video games"],
"dislikes": ["cats", "spiders"],
"occupation": "student",
"lastseen": "12.07.2021",
"nextcontact": "15.07.2021",
"notes": "He is a nice guy.",
"createdAt": "23.07.2021"
}
http://localhost:3002/api/person/60fabc01465fd12839091b25
{
"name": "Jimmy",
"metAt": "Taksim"
}
http://localhost:3002/api/person/60fabc01465fd12839091b25
Required values are name
, metAt
and createdAt
. For all rules checkout ./models/person-model.js