This project showcases a Dungeons & Dragons inventory application API built with Node.js & MongoDB. This API manages client requests to store, retrieve, and manage custom D&D items, user inventories, profile pictures, and more.
View Demo
Table of Contents
Live Client View: inventory-client-plum.vercel.app/
Front End: github.com/snaeem3/inventory-client
This project was inspired by a previous application: github.com/snaeem3/inventory-application
👥 User Management Endpoints: Handle client requests for signing up, logging in, updating profile pictures, editing inventory items, and tracking gold
🛠️ Catalog Item Endpoints: Handle requests to create, read, update, and delete custom items and item pictures.
🔐 Authentication Management: Use JSON web tokens to ensure only authorized users can send requests to the server
See the client project for planned features to the overall application
- Mongoose to connect to a MongoDB database
- Querying data from MongoDB
- CRUD (Create, Read, Update, and Delete) operations in MongoDB:
findByIdAndDelete()
,findByIdAndUpdate()
, etc. - Cloudinary to manage image storage and retrieval
- Multer to handle file upload requests from client
- JSON Web Token (JWT) for secure and verifiable user authentication
- Creation of token when users successfully log-in
- Token verification when users make certain requests (e.g. Blog post creation, comment deletion, etc.)
- User authentication with Passport.js
- LocalStrategy for username and password authentication
- Managing user sessions and serialization/deserialization
- Secure password hashing using bcrypt
- CORS to enable requests from specified routes
- Basic and Dynamic Routing (by item ID) using Express Router
- Middleware chaining in Express
- Defining and creating Models with various schema types
- Schema Virtual to return user's net worth
- Schema Sub Documents-
InventoryItemSchema
inmodels/user.js
- Controller modules (e.g.,
itemController
,userController
, etc.), adhering to the Model-View-Controller (MVC) architectural pattern and promoting code modularity - Express validator to validate and sanitize form data from the backend
- Asynchronous Error Handling
- App deployment with Vercel
To get a local copy up and running follow these simple steps.
Before you get started with this application, make sure you have the following prerequisites installed on your system:
- Node.js (version >= 18.12.1)
- npm (Node Package Manager)
To install the application and its dependencies, follow these steps:
-
Clone the repository:
git clone https://github.com/snaeem3/inventory-api.git cd inventory-api
-
Install the required packages:
npm install
-
Create a
.env
file in the root directory and configure the following variables:MONGODB_URI=your_mongodb_uri ACCESS_TOKEN_SECRET=your_jwt_access_token_code REFRESH_TOKEN_SECRET=your_jwt_refresh_token_code CLOUD_NAME="your_cloudinary_cloud_name" API_KEY="your_cloudinary_api_key" API_SECRET="your_cloudinary_api_secret"
Replace
your_mongodb_uri
with the MongoDB connection URI.Replace
your_jwt_access_token_code
andyour_jwt_refresh_token_code
with secret keys of your choosing.Replace
your_cloudinary_cloud_name
,your_cloudinary_api_key
, andyour_cloudinary_api_secret
with your Cloudinary credentials from the Cloudinary dashboard.
To run the application, you can use the following command:
npm start
Then, open the app in your web browser by navigating to http://localhost:3000.