Commander API is a simple ASP.NET Core 3.1 MVC REST API that executes CRUD (Create, Retrieve, Update and Delete) commands on an MS SQL Server Database using Entity Framework Core.
The Commander API stores command line snippets (e.g. dotnet new mvc - to create a new ASP.NET Core Web Application). It is a simple but useful tool when you need to find a specific command line to use it. So, you'll have it within your reach, quickly and without having to perform any search on Google ;).
Each command line will have the following attributes:
-
How to
Description of what the command will do, e.g. Build a .NET the project -
Command line
The actual command line snippet, e.g. dotnet build -
Platform
Application or platform domain, e.g. .Net Core
- Retrieve all commands
- Retrieve a spectic command
- Create a new command
- Update a command information
- Delete an existent command
As the most REST APIs, the Commander API will follow the standard set of methods to Create, Retrieve, Update, and Delete records in the database. So, each functionality could be access as listed in the table below:
Verb | URI | Method | Description |
---|---|---|---|
GET | /api/commands | Retrieve | Retrieve all command line |
GET | /api/commands/{id} | Retrieve | Retrieve a single resource, (by Id) |
POST | /api/commands | Create | Create a new command line |
PUT | /api/commands/{id} | Update | Update a single command line by Id |
DELETE | /api/commands/{id} | Delete | Delete a single command line by Id |
- .Net Core SDK installed;
- Visual Studio Code installed;
- Microsoft SQL Server Local DB installed;
- MS SQl Server - VSCode Extension - installed.
- Create a project's directory on your computer;
- Clone the repository.
git clone https://github.com/savaladaojr/CommanderAPI
- On the director that you clone the repository, by a command prompt, execute the command to open the Visual Sutdio Code and load the project folder. You should see something like the screenshot below.
code .
- In the Visual Studio Code, open a Terminal and run the command to restore all packages used by the API;
dotnet restore
-
Connect on the SQL Server Local DB:
1.1. Create a new database "CommanderDB";
1.2. Create new user called "CommanderUser", set it password and set it as a CommanderDB owner; -
In the VSCode:
2.1. Open the file "appsettings.json" and change the "ConnectionString" property to reflect your configuration;
2.2. Open a new Terminal and run the command to update the database with the project's database migrations.
dotnet ef database update
- Then rebuild the application;
dotnet build
- Run the API.
dotnet run
To run some tests on the API, I recommend that you download Postman or also use a Google Chrome plug-in. You also have another option which is Insomina. Both are gonna work and have a free version.
I'm using Postman! So I have already prepared a file with all requests for the API. You can find this file (Commands API.postman_collection.json) in the repository.
Exemple of a request to the API:
- Fork it (https://github.com/savaladaojr/CommanderAPI/fork);
- Create your feature branch (e.g.
git checkout -b feature/fooBar
); - Commit your changes (e.g.
git commit -am 'Add some fooBar'
); - Push to the branch (e.g.
git push origin feature/fooBar
); - Create a new Pull Request.