The Events Platform Backend is a Node.js application built with TypeScript and Express. It serves as the backend for an events management system, allowing users to create, manage, and sign up for events. The backend integrates with a PostgreSQL database using TypeORM and provides a RESTful API for the frontend application.
Production: goldfish-app-h4yjf.ondigitalocean.app
- User authentication and authorization
- Event creation, updating, and deletion
- User registration and management
- Integration with Google Calendar API for event scheduling
- Swagger UI for API documentation
- Unit and integration testing with Jest
- Node.js: JavaScript runtime for building server-side applications
- TypeScript: Superset of JavaScript that adds static types
- Express: Web framework for Node.js
- TypeORM: ORM for TypeScript and JavaScript
- PostgreSQL: Relational database management system
- Jest: Testing framework for JavaScript
- Swagger: API documentation tool
- Node.js (v14 or higher)
- PostgreSQL (v12 or higher)
- TypeScript (v4 or higher)
-
Clone the repository:
git clone cd
-
Create a PostgreSQL database: Before running the application, you need to create a PostgreSQL database. You can do this by connecting to your PostgreSQL server and running the following command:
CREATE DATABASE events_db;
-
Set up Google Credentials: To integrate with Google Calendar, you need to set up Google API credentials:
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to "APIs & Services" > "Credentials".
- Click on "Create Credentials" and select "OAuth 2.0 Client IDs".
- Configure the consent screen and set the application type to "Web application".
- Add your redirect URI (e.g.,
http://localhost:3000/auth/google/calender/callback
). - Save your credentials and note down the
Client ID
andClient Secret
.
-
Set up environment variables: Create a
.env
file in the root directory and add the following variables. You can use the.env.example
file as a reference:NODE_ENV = 'development' or 'production' CORS_ORIGIN=http://localhost:3000 FRONTEND_URL=http://localhost:3000 or prod URL PORT=3000 DB_HOST=localhost DB_PORT=5432 DB_USERNAME=your_db_username DB_PASSWORD=your_db_password DB_NAME=your_dd_name JWT_SECRET=your_jwt_secret GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/calender/callback GOOGLE_CALENDER_CLIENT_ID=your_google_calendar_client_id GOOGLE_CALENDER_CLIENT_SECRET=your_google_calendar_client_secret GOOGLE_CALENDER_REDIRECT_URI=http://localhost:3000/auth/google/calender/callback SUPER_ADMIN_EMAIL=your_super_admin_email SUPER_ADMIN_PASSWORD=your_super_admin_password
-
Run database migrations:
npm run typeorm migration:run
-
Start the server:
npm run dev
The API is documented using Swagger. Once the server is running, you can access the documentation at:
https://goldfish-app-h4yjf.ondigitalocean.app/api-docs
To run the tests, use the following command:
npm test
npm run test:watch
src/
├── adapter/
│ ├── controllers/ # Controllers for handling requests
│ ├── middleware/ # Middleware for authentication and authorization
│ └── routes/ # API routes
├── application/ # Application logic and use cases
├── infrastructure/ # Database and external service integrations
├── utils/ # Utility functions
├── app.ts # Main application file
├── server.ts # Server entry point
└── infrastructure/repository/ # Database repositories
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/YourFeature
) - Make your changes
- Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/YourFeature
) - Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
The following scripts are available for managing the application:
npm run build
: Compiles the TypeScript code into JavaScript.npm run start
: Starts the application in production mode.npm run dev
: Starts the application in development mode with hot reloading.npm run typeorm
: Runs TypeORM CLI commands.npm run migration:generate
: Generates a new migration file.npm run migration:run
: Runs the pending migrations.npm run migration:revert
: Reverts the last executed migration.npm run migration:show
: Shows the current migrations.npm test
: Runs the test suite.npm run test:watch
: Runs tests in watch mode.npm run test:coverage
: Runs tests and generates a coverage report.npm run test:unit
: Runs unit tests.
The application requires several environment variables to be set. You can use the .env.example
file as a reference to create your own .env
file. Here are the required variables: