edilsobai / dream-team

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dream Team Creator

This is a simple application built using the Express framework that allows clients to create a dream team of players. The application can receive GET, POST, and PUT requests, allowing clients to retrieve information about available players, create new dream teams by selecting a group of players, and update the player information.

Installation

To use this application, you'll need to have__ Node.js__ and MySQL installed on your machine. Once you have Node.js and MySQL installed, you can clone this repository to your local machine using the following command:

git clone https://github.com/your-username/dream-team-creator.git

Once you've cloned the repository, you can navigate to the project directory and install the necessary dependencies by running the following command:

npm install

Configuration

Before running the application, you need to create a database in MySQL and update the knexfile.js with your database configuration. You can update the following fields in the configuration:

development: { client: 'mysql', connection: { host: process.env.DB_HOST, user: process.env.DB_USER, password: process.env.DB_PASSWORD, database: process.env.DB_NAME } }

To avoid storing sensitive information such as database credentials in plain text in the knexfile.js file, we can use the dotenv package. To use dotenv, create a .env file in the project root directory and add the following lines:

DB_HOST=localhost DB_USER=root DB_PASSWORD=yourpassword DB_PORT = 3306 DB_NAME=dream_team

Usage

To start the server, you can run the following command:

npm start

Once the server is running, you can access the application by navigating to http://localhost:3000/ in your web browser.

GET Request

To retrieve information about available players, you can send a GET request to http://localhost:3000/players. This will return a page containing information about the available players.

POST Request

To create a new dream team, you can send a POST request to http://localhost:3000/players or fill out the form in http://localhost:3000/ using a Form or in JSON format containing the selected player. The format of the JSON object should be as follows:

{ "name": "player name",
"country": "player country",
"club": "player club", "position": "player position" }

Put Request

To update an existing player by name, you can send a PUT request to http://localhost:3000/players/update/:player_name with the following request parameters:

{ "name": "player name",
"country": "new player country",
"club": "new player club", "position": "new player position" }

Data Storage

This application uses MySQL to store and retrieve data. The schema for the database is defined in the schema.sql file, and the seed data for the database is defined in the seed.sql file.

Contributing

If you find any bugs or issues with this application, feel free to open an issue on GitHub or submit a pull request with your proposed changes. We welcome contributions from the community!

License

This project is licensed under the MIT License. See the LICENSE file for more information.

About

License:MIT License


Languages

Language:EJS 54.1%Language:JavaScript 45.9%