Skip to content

This is a Node.js and MongoDB-based multitenant backend application for managing organizations, users, and stores. The application provides REST API endpoints for creating, retrieving, updating, and deleting organizations, users, and stores.

License

Notifications You must be signed in to change notification settings

wise4rmgod/Multitenant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multitenant

This is a Node.js and MongoDB-based multitenant backend application for managing organizations, users, and stores. The application provides REST API endpoints for creating, retrieving, updating, and deleting organizations, users, and stores.

Make sure you have mongod installed via this link https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/

  • Start mongod on Mac using this command brew services start mongodb/brew/mongodb-community and
  • Stop mongod using this command brew services stop mongodb-community@6.0

Features

  • Organization registration with basic information such as name, email, department, and password.
  • User registration linked to organizations, including user details and role.
  • Users can create private or public stores with store details like name, description, and link.

Technologies Used

  • Node.js
  • Express.js
  • MongoDB (via Mongoose)

Getting Started

  1. Clone this repository:
git clone https://github.com/your-username/organization-app.git
cd organization-app
  1. Install the dependencies:
npm install
  1. Configure MongoDB:

Update the MongoDB connection URL in server.js to point to your MongoDB instance.

  1. Start the server:
node server.js

The server will run on http://localhost:3000 by default. You can now use API endpoints to interact with the application.

API Endpoints

Base URL

The base URL for our API is: https://app-59001.on-aptible.com/

Making Requests

Our API uses the HTTP protocol, and requests are made using the appropriate HTTP methods. The data is typically sent and received in JSON format.

Error Handling

Our API returns standard HTTP status codes to indicate the outcome of a request. Additionally, the response body may include an error object with more details.

Here are some standard error status codes and their meanings:

  • 400 Bad Request: The request was malformed or had invalid parameters.
  • 401 Unauthorized: The request lacks valid authentication credentials.
  • 403 Forbidden: The authenticated user does not have permission to access the requested resource.
  • 404 Not Found: The requested resource was not found.
  • 500 Internal Server Error: An unexpected error occurred on the server.

Below are some of the key API endpoints you can start using:

Organization Registration:

Create an Organization:

  • Method: POST
  • Endpoint: /organizations
  • Request Body:
{
  "name": "Organization Name",
  "email": "organization@example.com",
  "department": "IT",
  "password": "organizationPassword"
}
  • Response: Newly created organization details

Get All Organizations:

  • Method: GET
  • Endpoint: /organizations
  • Response: List of all organizations

Get a Specific Organization:

  • Method: GET
  • Endpoint: /organizations/:id
  • Response: Details of the specified organization

Update an Organization:

  • Method: PUT
  • Endpoint: /organizations/:id
  • Request Body:
{
  "name": "New Organization Name",
  "email": "new@example.com",
  "department": "HR"
}
  • Response: Updated organization details

Users Registration:

Create a User:

  • Method: POST
  • Endpoint: /organizations/:orgId/users
  • Request Body:
{
  "name": "User Name",
  "email": "user@example.com",
  "password": "userPassword",
  "role": "employee"
}
  • Response: Newly created user details

Get All Users for an Organization:

  • Method: GET
  • Endpoint: /organizations/:orgId/users
  • Response: List of users in the specified organization

Update a User:

  • Method: PUT
  • Endpoint: /users/:id
  • Request Body:
{
  "name": "Updated User Name",
  "role": "manager"
}
  • Response: Updated user details

Stores Management:

Create a Store for a User:

  • Method: POST
  • Endpoint: /users/:userId/stores
  • Request Body:
{
  "name": "Store Name",
  "description": "Store Description",
  "link": "storelink.com"
}
  • Response: Newly created store details

Get All Stores for a User:

  • Method: GET
  • Endpoint: /users/:userId/stores
  • Response: List of stores owned by the user

Contributing

Contributions are welcome! Feel free to open issues or pull requests for improvements or bug fixes.

License

This project is licensed under the MIT License.

About

This is a Node.js and MongoDB-based multitenant backend application for managing organizations, users, and stores. The application provides REST API endpoints for creating, retrieving, updating, and deleting organizations, users, and stores.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published