Giter VIP home page Giter VIP logo

cretaceouspark.solution's Introduction

Cretaceous Park API

Practice building an API

By: Michelle Morin, Joseph Wangemann, Jonathan Carlos, Kristina Hengster Tintor, April 2, 2020

Description

This API allows users to GET, POST, PUT, and DELETE animals of the cretaceous period.

Specification user stories:

  • A user is able to GET, POST, PUT, and DELETE animals.
  • A user is able to view details for a specific animal, based on AnimalId.
  • A user is able to GET animals by species, gender, and/or name.

Endpoints:

All endpoints have a host of 'localhost:5004' and base path of '/api'

  • '/animals'
    • GET request
    • returns list of all animals matching search parameters gender, species, and/or name, or all animals if no search parameters are used.
  • '/animals'
    • POST request, requires body of animal object formatted in JSON
    • returns nothing, but adds an entry of an animal to the cretaceous_park database table animals
  • '/animals/{id}'
    • GET request
    • returns details for a specific animal
  • '/animals/{id}'
    • PUT request, requires a body of an animal object formatted in JSON
    • returns nothing, but updates an existing entry in the animals table of the cretaceous_park database
  • '/animals/{id}'
    • DELETE request
    • returns nothing, but removes an existing entry from the animals table of the cretaceous_park database

Setup/Installation Requirements

Install .NET Core

on macOS:

  • Click here to download a .NET Core SDK from Microsoft Corp.
  • Open the file (this will launch an installer which will walk you through installation steps. Use the default settings the installer suggests.)

on Windows:

  • Click here to download the 64-bit .NET Core SDK from Microsoft Corp.
  • Open the .exe file and follow the steps provided by the installer for your OS.

Install dotnet script

Enter the command dotnet tool install -g dotnet-script in Terminal (macOS) or PowerShell (Windows).

Install MySQL

on macOS:

Download the MySQL Community Server DMG File here. Follow along with the installer until you reach the configuration page. Once you've reached Configuration, set the following options (or user default if not specified):

  • use legacy password encryption
  • set password (and change the password field in appsettings.json file of this repository to match your password)
  • click finish
  • open Terminal and enter the command echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile if using Git Bash.
  • Verify MySQL installation by opening Terminal and entering the command mysql -uroot -p{your password here, omitted brackets}. If you gain access to the MySQL command line, installation is complete. An error (e.g., -bash: mysql: command not found) indicates something went wrong.

on Windows:

Download the MySQL Web Installer here and follow along with the installer. Click "Yes" if prompted to update, and accept license terms.

  • Choose Custom setup type
  • When prompted to Select Products and Features, choose the following: MySQL Server (Will be under MySQL Servers) and MySQL Workbench (Will be under Applications)
  • Select Next, then Execute. Wait for download and installation (can take a few minutes)
  • Advance through Configuration as follows:
    • High Availability set to Standalone.
    • Defaults are OK under Type and Networking.
    • Authentication Method set to Use Legacy Authentication Method.
    • Set password to epicodus. You can use your own if you want but epicodus will be assumed in the lessons.
    • Unselect Configure MySQL Server as a Windows Service.
  • Complete installation process

Add the MySQL environment variable to the System PATH. Instructions for Windows 10:

  • Open the Control Panel and visit System > Advanced System Settings > Environment Variables...
  • Select PATH..., click Edit..., then Add.
  • Add the exact location of your MySQL installation and click OK. (This location is likely C:\Program Files\MySQL\MySQL Server 8.0\bin, but may differ depending on your specific installation.)
  • Verify installation by opening Windows PowerShell and entering the command mysql -uroot -p{your password here, omitted brackets}. It's working correctly if you gain access to the MySQL command line. Exit MySQL by entering the command exit.

Clone this repository

Enter the following commands in Terminal (macOS) or PowerShell (Windows):

  • cd desktop
  • git clone followed by the URL to this repository
  • cd CretaceousPark.Solution/CretaceousPark

Confirm that you have navigated to the CretaceousPark directory (e.g., by entering the command pwd in Terminal).

Recreate the cretaceous_park database using the following commands (in Terminal on macOS or PowerShell on Windows) at the root of the CretaceousPark directory:

  • dotnet restore
  • dotnet build
  • dotnet ef database update

Run this application by entering the following command in Terminal (macOS) or PowerShell (Windows) at the root of the CretaceousPark directory:

  • dotnet run or dotnet watch run
  • With the API running, open the Swagger UI to view and test the different routes of this API!

To view/edit the source code of this application, open the contents of the CretaceousPark.Solution directory in a text editor or IDE of your choice (e.g., to open all contents of the directory in Visual Studio Code on macOS, enter the command code . in Terminal at the root of the CretaceousPark.Solution directory).

Technologies Used

  • Git 2.23.0
  • C# language
  • .NET Core 2.2.106
  • dotnet script 0.50.1
  • Visual Studio Code 1.43.1
  • Model-View-Controller(MVC) framework
  • MySQL 8.0.15
  • MySQL Workbench 8.0.15
  • Entity Framework Core 2.2.4
  • Language-Integrated Query (LINQ)
  • ASP.NET Razor
  • GitBash
  • Swagger 2.0 documentation (swagger.json)
  • NSwag

License

Licensed under the MIT license.

© 2020 - Michelle Morin, Joseph Wangemann, Jonathan Carlos, Kristina Hengster Tintor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.