Skip to content

willyprayogo26/mongoose-crud

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongoose-crud

List of basic routes:

Route HTTP Header(s) Body Description
/registerAdmin POST none email: String
password: String
Create a user (role auto admin)
success:
(201), example: {"_id": String, "email": String, "password": String, "role": String}
errors:
(500), error
/register POST none email: String
password: String
Create a user (role auto user)
success:
(201), example: {"_id": String, "email": String, "password": String, "role": String}
errors:
(500), error
/login POST none email: String
password: String
Login and get token based on credentials
success:
(200), example: {"_id": String, "email": String, "password": String, "role": String, "token": String}
errors:
(400), {message: 'Invalid email/password'}
(500), error

List of member routes:

Route HTTP Header(s) Body Description
/members GET Authenticated:
(token),
Authorized:
(role: admin)
none Get all members info (Admin only)
success:
(200), example: [{"_id": String, "email": String, "password": String, "role": String}, {"_id": String, "email": String, "password": String, "role": String}, etc]
errors:
(500), error
/members/:id GET Authenticated:
(token)
none Get a single member info (Admin and authenticated member)
success:
(200), example: {"_id": String, "email": String, "password": String, "role": String}
errors:
(404), example: {message: 'Member not found'}
(500), error
/members POST Authenticated:
(token),
Authorized:
(role: admin)
email: String
password: String
role: String
Create a member (admin only)
success:
(201), example: {"_id": String, "email": String, "password": String, "role": String}
errors:
(500), error
/members/:id PUT Authenticated:
(token)
email: String Update a member with new info (admin and authenticated member)
success:
(200), example: {message: 'Updated'}
errors:
(404), example: {message: 'Member not found'}
(500), error
/members/:id DELETE Authenticated:
(token),
Authorized:
(role: admin)
none Delete a member (admin only)
success:
(200), example: {message: 'Deleted'}
errors:
(404), example: {message: 'Member not found'}
(500), error

List of book routes:

Route HTTP Header(s) Body Description
/books GET Authenticated:
(token)
none Get all books info
success:
(200), example: [{"_id": String, "isbn": String, "title": String, "author": String, "category": String, "stock": String}, {"_id": String, "isbn": String, "title": String, "author": String, "category": String, "stock": String}, etc]
errors:
(500), error
/books/:id GET Authenticated:
(token)
none Get a single book info
success:
(200), example: {"_id": String, "isbn": String, "title": String, "author": String, "category": String, "stock": String}
errors:
(404), example: {message: 'Book not found'}
(500), error
/books POST Authenticated:
(token),
Authorized:
(role: admin)
email: String
password: String
role: String
Create a book (admin only)
success:
(201), example: {"_id": String, "isbn": String, "title": String, "author": String, "category": String, "stock": String}
errors:
(500), error
/books/:id PUT Authenticated:
(token)
Authorized:
(role: admin)
email: String Update a book with new info (admin only)
success:
(200), example: {message: 'Updated'}
errors:
(404), example: {message: 'Book not found'}
(500), error
/books/:id DELETE Authenticated:
(token),
Authorized:
(role: admin)
none Delete a book (admin only)
success:
(200), example: {message: 'Deleted'}
errors:
(404), example: {message: 'Book not found'}
(500), error

List of transaction routes:

Route HTTP Header(s) Body Description
/transactions GET Authenticated:
(token)
Authorized:
(role: admin)
none Get all transaction info (admin only)
success:
(200), example: [{"_id": String, "member": String, "in_date": String, "out_date": String, "due_date": String, "fine": Number, "booklist": [{book1}, {book2}]}, {"_id": String, "member": String, "in_date": String, "out_date": String, "due_date": String, "fine": Number, "booklist": [{book1}, {book2}]}, etc]
errors:
(500), error
/transactions/:id GET Authenticated:
(token)
Authorized:
(role: admin)
none Get a single transaction info (admin only)
success:
(200), example: {"_id": String, "member": String, "in_date": String, "out_date": String, "due_date": String, "fine": Number, "booklist": [{book1}, {book2}]}
errors:
(404), example: {message: 'Transaction not found'}
(500), error
/transactions POST Authenticated:
(token),
Authorized:
(role: admin)
email: String
password: String
role: String
Create a transaction (admin only)
success:
(201), example: {"_id": String, "member": String, "in_date": String, "out_date": String, "due_date": String, "fine": Number, "booklist": [{book1}, {book2}]}
errors:
(404), example: {"message": "Transaction failed"}
(500), error
/transactions/:id PUT Authenticated:
(token)
Authorized:
(role: admin)
email: String Update a transaction with new info (admin only)
success:
(200), example: {"_id": String, "member": String, "in_date": String, "out_date": String, "due_date": String, "fine": Number, "booklist": [{book1}, {book2}]}
errors:
(404), example: {message: 'Transaction not found'}
(500), error
/transactions/:id DELETE Authenticated:
(token),
Authorized:
(role: admin)
none Delete a transaction (admin only)
success:
(200), example: {message: 'Transaction successfully deleted'}
errors:
(404), example: {message: 'Transaction not found'}
(500), error

List of filter routes:

Route HTTP Description
/books?<key>=<value> GET Get books by spesific key and value
Example:
http://localhost:3000/books/?title=Dora
http://localhost:3000/books/?author=Willy
http://localhost:3000/books/?category=fantasy
success:
(200), example: [{"_id": String, "isbn": String, "title": String, "author": String, "category": String, "stock": String}, {"_id": String, "isbn": String, "title": String, "author": String, "category": String, "stock": String}, etc]
errors:
(500), error
/transactions?<key>=<value> GET Get transactions by spesific key and value from book
Example:
http://localhost:3000/transactions/?_id=`<br />http://localhost:3000/transactions/?isbn=<br />http://localhost:3000/transactions/?category=`
success:
(200), example: [{"_id": String, "member": String, "in_date": String, "out_date": String, "due_date": String, "fine": Number, "booklist": [{book1}, {book2}]}, {"_id": String, "member": String, "in_date": String, "out_date": String, "due_date": String, "fine": Number, "booklist": [{book1}, {book2}]}, etc]
errors:
(500), error

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%