This is the backend server for the myCryptoFolio application. It is built with Node.js, Express, and MongoDB.
- User Authentication: Secure user registration and login with hashed passwords, JWT tokens, and cookies.
- Portfolio Management: APIs to add, edit, and delete transactions for each cryptocurrency.
- Email Notifications: Reset password and account verification through email using Nodemailer.
- Data Validation: Uses Joi for data validation.
- Rate Limiting: Protects APIs from excessive requests using express-rate-limit.
- Unit Testing: Implements tests using Jest.
- Automatic Restart: Uses Nodemon for automatic server restarts during development.
- Node.js
- Express
- MongoDB
- Mongoose
- Express-rate-limit
- Argon2
- Cookie Parser
- JSON Web Token
- Nodemailer
- Joi
- Jest
- Nodemon
-
Clone the repository:
git clone https://github.com/boris-picard/mycryptofolio-backend.git cd mycryptofolio-backend
-
Install dependencies:
npm install
-
Create a
.env
file with the following content:MONGO_URI=your_mongo_db_uri JWT_SECRET=your_jwt_secret PORT=3001 EMAIL_USER=your_email EMAIL_PASS=your_email_password
-
Run the development server:
npm run dev
-
The server will start on
http://localhost:3001
.
POST /api/auth/signup
: Register a new user.POST /api/auth/signin
: Login a user.POST /api/auth/refresh-token
: Refresh JWT token.POST /api/auth/resend-email
: Resend verification email.POST /api/auth/forgot-password
: Send reset password email.POST /api/auth/reset-password
: Reset password.GET /api/auth/user
: Get user details.GET /api/auth/verify-email
: Verify user email.DELETE /api/auth/logout
: Logout a user.
POST /api/coins/createTransaction
: Create a new coin and transaction.GET /api/coins/detailed/:id
: Get detailed transactions for a coin.PUT /api/coins/:id
: Update a coin.
POST /api/transactions/name/:name
: Create a new transaction for a specific coin.GET /api/transactions/portfolio
: Get all coins in the portfolio.GET /api/transactions/id/:id
: Get a specific coin by ID.GET /api/transactions/name/:name
: Get a specific coin by name.PUT /api/transactions/id/:id
: Update a specific transaction.DELETE /api/transactions/:id
: Delete a coin and its transactions.DELETE /api/transactions/id/delete/:id
: Delete a specific transaction.
npm start
: Starts the production server.npm run dev
: Starts the development server with Nodemon.npm test
: Runs the test suite using Jest.
Contributions are welcome! Please create a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.