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
- 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.
- Node.js
- Express.js
- MongoDB (via Mongoose)
- Clone this repository:
git clone https://github.com/your-username/organization-app.git
cd organization-app
- Install the dependencies:
npm install
- Configure MongoDB:
Update the MongoDB connection URL in server.js
to point to your MongoDB instance.
- 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.
The base URL for our API is: https://app-59001.on-aptible.com/
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.
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:
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
- Method: GET
- Endpoint: /organizations
- Response: List of all organizations
- Method: GET
- Endpoint: /organizations/:id
- Response: Details of the specified organization
- Method: PUT
- Endpoint: /organizations/:id
- Request Body:
{
"name": "New Organization Name",
"email": "new@example.com",
"department": "HR"
}
- Response: Updated organization details
- Method: POST
- Endpoint: /organizations/:orgId/users
- Request Body:
{
"name": "User Name",
"email": "user@example.com",
"password": "userPassword",
"role": "employee"
}
- Response: Newly created user details
- Method: GET
- Endpoint: /organizations/:orgId/users
- Response: List of users in the specified organization
- Method: PUT
- Endpoint: /users/:id
- Request Body:
{
"name": "Updated User Name",
"role": "manager"
}
- Response: Updated user details
- Method: POST
- Endpoint: /users/:userId/stores
- Request Body:
{
"name": "Store Name",
"description": "Store Description",
"link": "storelink.com"
}
- Response: Newly created store details
- Method: GET
- Endpoint: /users/:userId/stores
- Response: List of stores owned by the user
Contributions are welcome! Feel free to open issues or pull requests for improvements or bug fixes.
This project is licensed under the MIT License.