notepad-api
Api for the notepad application
You can deploy the notepad application yourself. See the live example
https://notepad-api-datcal.herokuapp.com
Docs
Set up
First, clone the repo. Copy the .env.example
file to .env
(which will be ignored by Git):
cp .env.example .env
Configuring Database
- Go to the MongoDB Atlas Console and create a new database
- Get to database uri and paste this in your .env file
Configuring JWT
- Define a secret key and enter in your .env file
API_SECRET_KEY=SOME_LONG_TEXT
Configuring Test Process
- Define test user mail and password and enter it into your .env file
TESTUSER=email
TESTUSERPASSWORD=password
Run Your Project
In the project folder, run:
npm install
npm start
Notes
Route | HTTP Verb | POST body | Header | Description |
---|---|---|---|---|
/notes | GET |
Empty | x-access-token=token | List all notes. |
/notes | POST |
{'content':'foo'} | x-access-token=token | Create a new note. |
/notes/:id | GET |
Empty | x-access-token=token | Get a note. |
/notes/:id | PUT |
{'content':'bar'} | x-access-token=token | Update a note with new info. |
/notes/:id | DELETE |
Empty | x-access-token=token | Delete a note. |
User
Route | HTTP Verb | POST body | Description |
---|---|---|---|
/user/register | POST |
{'mail' : 'test@test.com', 'password' : 'password','fullname' : 'Name Surname'} | Create a new user. |
/user/login | POST |
{'mail' : 'test@test.com', 'password' : 'password'} | Login user and generate a token. |