ALX Files Manager is a simple file management API built with Node.js, Express, and MongoDB. It allows users to upload, download, manage, and share files.
- User authentication and authorization
- Upload and download files
- Manage file permissions (public/private)
- Generate image thumbnails
- Send welcome emails to new users
- Clone the repository:
git clone https://github.com/alantiren/alx-files_manager.git
- Install dependencies:
cd alx-files_manager
npm install
- Set up environment variables:
Create a .env
file in the root directory and add the following variables:
DB_HOST=localhost
DB_PORT=27017
DB_NAME=files_manager
DB_USER=username
DB_PASS=password
- Start the server:
npm start
The server should now be running on http://localhost:5000.
To access protected endpoints, you need to obtain an authentication token by sending a POST request to /connect
with your credentials. Use the token in subsequent requests by including it in the Authorization
header.
Example:
curl -X POST http://localhost:5000/connect -d "username=user&password=pass"
- GET /status: Check server status.
- GET /stats: Get server statistics.
- POST /users: Create a new user.
- GET /connect: Get authentication token.
- GET /disconnect: Revoke authentication token.
- GET /users/me: Get current user details.
- POST /files: Upload a file.
- GET /files/:id: Get details of a file.
- GET /files: Get list of files (pagination supported).
- PUT /files/:id/publish: Publish a file.
- PUT /files/:id/unpublish: Unpublish a file.
- GET /files/:id/data: Get file data.
- (Other endpoints as per your implementation)
To run tests:
npm test