2.6 KiB
RememberMe
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.
Features
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
Usage
npm install- You'll need to install MongoDB either locally or from the cloud. Once you get your connection string change
./startup/db.jsconnection string to your MongoDB adress. - You'll need token in order to use REST API. Your private key comes from
process.env.rememberMe_jwtkeyso 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.jsand you are ready.- Server port starts at
3002if undefined. You can define the port by usingprocess.env.portenvironment.
- Server port starts at
Rest API
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.
GET
GET all entries
http://localhost:3002/api/person/
GET by name
http://localhost:3002/api/person/get/Mike
GET by ID
http://localhost:3002/api/person/60fabc01465fd12839091b25
POST
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"
}
PUT by ID
http://localhost:3002/api/person/60fabc01465fd12839091b25
{
"name": "Jimmy",
"metAt": "Taksim"
}
DELETE by ID
http://localhost:3002/api/person/60fabc01465fd12839091b25
Required Values
Required values are name, metAt and createdAt. For all rules checkout ./models/person-model.js