Backend Web App for creating storing and sharing notes app
- Framework: ExpressJS
- DB: Postgres DB
- ORM: Sequelize
- Easy signup to create user account
- Authentification and Authorisation enabled using JWT tokens and hashing
- Create new note, fetch all created notes, update and delete it as you want
- Note sharing
- Enabled fast and accurate full text search with keywords on the notes created using postgres ts_vector and ts_query which tokenizes content of the word after lexical processing and then uses inverted index and ranking mechanism on it.
- API rate limiter to throttle heavy load
- Sequelize ORM to sync database, create table and easy insert search functionality without going inside postgres CLI
- Install Postgres
sudo apt update
sudo apt install postgresql postgresql-contrib
- Start and enable Postgres
sudo systemctl start postgresql
sudo systemctl enable postgresql
- Create Postgres User
sudo -u postgres createuser --interactive
- Create Postgres Database
sudo -u postgres createdb <your_username>
- Access PostgreSQL Shell
sudo -u postgres psql
- Setup a password for the User
\password <your_username>
- Exit Postgres shell
\q
- Step 1: Create config folder inside app
mkdir app/config
cd config
- Step 2: Add config files
touch app-config.js
touch db-config.js
- Step 3: app-config.js sample
module.exports ={
port: 4000,
SECRET_KEY: 'RTwEYNjU71sdRJbG6M6LOuF0CirfisUe',
SESSION_KEY: 'o7Gnbw9otu',
SALTING: 10,
TOKEN_EXPIRY : '1h',
MAX_REQUEST: 15,
TIME_RANGE_IN_MS: 600000
};
- Step 4 db-config.js sample
module.exports ={
HOST: "localhost",
USER: "postgres",
PASSWORD: "123456",
DB: "notesdb",
PORT: 5432
};
npm init
npm install
node index.js
This documentation provides details on the endpoints available in the Notes Backend API.
- Method: POST
- URL:
http://localhost:4000/auth/signup
- Body:
- Mode: Raw
- Content-Type: application/json
- Raw Data:
{ "username": "shadan1", "password": "123456", "name": "shadan" }
No specific response details are provided.
- Method: POST
- URL:
http://localhost:4000/auth/login
- Body:
- Mode: Raw
- Content-Type: application/json
- Raw Data:
{ "username": "shadan", "password": "123456" }
No specific response details are provided.
- Method: POST
- URL:
http://localhost:4000/notes/create
-
Authentication:
- Type: apikey
- Key: authorization
- Value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo1LCJpYXQiOjE3MDQ3MjgyNjcsImV4cCI6MTcwNDczMTg2N30.juQhWCjCYKYi9fNMhl9Mpw65YmH1QMQr3IUFEas3EdU"
-
Body:
- Mode: Raw
- Content-Type: application/json
- Raw Data:
{ "title": "new13", "content": "In the heart of a meadow, wildflowers swayed in the breeze, a vibrant sea of colors. Bees hummed in orchestrated chaos, collecting natures nectar. The warmth of the sun kissed the landscape, and the rustle of grass whispered tales of seasons changing, a timeless ode to the cycles of life." }
No specific response details are provided.
- Method: GET
- URL:
http://localhost:4000/notes
- Authentication:
- Type: apikey
- Key: authorization
- Value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo1LCJpYXQiOjE3MDQ3MzM3MjQsImV4cCI6MTcwNDczNzMyNH0.wytEx93PvaKPONLfL7TcyubRi-6RMepI1DKuTxQt3YU"
No specific response details are provided.
- Method: GET
- URL:
http://localhost:4000/notes/:id
-
Authentication:
- Type: apikey
- Key: authorization
- Value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxLCJpYXQiOjE3MDQ3MTcxMTEsImV4cCI6MTcwNDcyMDcxMX0.UADugPt513txdjHg_dZBxtMaZKNBQ6rrxYIG8p-l9XE"
-
Variable:
id
: 12
No specific response details are provided.
- Method: GET
- URL:
http://localhost:4000/notes/:id/share
-
Authentication:
- Type: apikey
- Key: authorization
- Value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo1LCJpYXQiOjE3MDQ3MzcyOTQsImV4cCI6MTcwNDc0MDg5NH0.shxt7bLczUTNcHVsPyaLAqlNYl1eibUvF1uvUZSh_Eo"
-
Variable:
id
: 6
No specific response details are provided.
- Method: GET
- URL:
http://localhost:4000/search?keyword=symphony
- Authentication:
- Type: apikey
- Key: authorization
- Value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo1LCJpYXQiOjE3MDQ3MzM3MjQsImV4cCI6MTcwNDczNzMyNH0.wytEx93PvaKPONLfL7TcyubRi-6RMepI1DKuTxQt3YU"
No specific response details are provided.
- Method: DELETE
- URL:
http://localhost:4000/notes/delete/:id
-
Authentication:
- Type: apikey
- Key: authorization
- Value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo1LCJpYXQiOjE3MDQ3MjI5NDcsImV4cCI6MTcwNDcyNjU0N30.FWI51_IuSoVmGmjT-s55ssnkKBPM8mp8LkZSX28rVhk"
-
Variable:
id
: 1
No specific response details are provided.
- Method: PUT
- URL:
http://localhost:4000/notes/update/:id
-
Authentication:
- Type: apikey
- Key: authorization
- Value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxLCJpYXQiOjE3MDQ3MjQzMjQsImV4cCI6MTcwNDcyNzkyNH0.Ipf9dKertT9lTMVgh_01ZJuXWNRY7WU5dvJs4kVnYfA"
-
Body:
- Mode: Raw
- Content-Type: application/json
- Raw Data:
{ "content": "update check Wayne Rooney boss ENgland" }
-
Variable:
id
: 1
No specific response details are provided.