https://github.com/dewanshrawat15/polydian-backend
https://github.com/dewanshrawat15/polydian-backend
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dewanshrawat15/polydian-backend
- Owner: dewanshrawat15
- License: mit
- Created: 2021-03-26T15:56:36.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-31T06:43:14.000Z (almost 4 years ago)
- Last Synced: 2025-02-09T12:15:11.490Z (3 months ago)
- Language: JavaScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Polydian Backend
A server to generate new notes out of any website.## Setting up
### Installing and setting up MongoDB
- Install MongoDB Community edition
- Start mongodb as a service
- Install MongoDB Compass### Installing project dependencies
- Run ```yarn``` or ```npm install```
- Run ```yarn start``` or ```npm run start``` to run this project.
- Add a ```.env``` file, with a ```MONGO_URI``` variable specifying the mongodb URL, and assign the ```TOKEN_SECRET``` variable a value similar to the key hash generated by ```crypto.randomBytes(128).toString('hex')```.## Database schema
- User table schema
```
username: {type: String, required: true},
firstName: {type: String, required: true},
lastName: {type: String, required: true},
hash: {type: String, required: true},
salt: {type: String, required: true}
```
- AuthToken table schema
```
authToken: {type: String, required: true},
username: {type: String, required: true}
```## API Endpoints
#### ```/users/all```
##### GET Request
An API endpoint to fetch all users#### ```/users/create```
##### POST Request
An API endpoint that creates a new entry in the users table and an entry in the auth token table for the user.#### ```/users/delete/all```
##### GET Request
An API endpoint that deletes all users and auth tokens from the users table and the auth token tables.#### ```/users/login```
##### POST Request
An API endpoint to authenticate a user, and return an auth token corresponding to the user.#### ```/users/password/update```
##### POST Request
An API endpoint to update password for a user.#### ```/note```
##### GET Request
Fetch all notes corresponding to a user from the authorisation token specified in the headers.##### POST Request
Create a new note corresponding to the user from the authorisation token specified in the headers.#### ```/note/delete```
##### POST Request
Delete note if authorised, corresponding to note ID.