https://github.com/bilal-fazlani/litedb.autoapi
Want to create an api without writing code?
https://github.com/bilal-fazlani/litedb.autoapi
asp-net-core aspnet-web-api dotnet-core litedb testing-tool
Last synced: 8 months ago
JSON representation
Want to create an api without writing code?
- Host: GitHub
- URL: https://github.com/bilal-fazlani/litedb.autoapi
- Owner: bilal-fazlani
- License: mit
- Created: 2018-03-10T19:56:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-04-19T12:24:58.000Z (about 6 years ago)
- Last Synced: 2025-09-23T07:36:08.711Z (9 months ago)
- Topics: asp-net-core, aspnet-web-api, dotnet-core, litedb, testing-tool
- Language: C#
- Homepage:
- Size: 9.77 KB
- Stars: 6
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LiteDb.AutoApi
Want to create an api without writing code?
[](https://ci.appveyor.com/project/bilal-fazlani/litedb-autoapi)
[](https://ci.appveyor.com/project/bilal-fazlani/litedb-autoapi/build/tests)
[](https://www.nuget.org/packages/LiteDB.AutoApi/)
This library let's you create CRUD apis in dotnet core without writing any controller, service or database code.
All you have to do is define your model... and that's it. This library will then expose
- CREATE
- UPDATE
- DELETE
- LIST
- GET
These endpoints will persinst your data using a litedb. If you don't what litedb is, please check it out here -> http://www.litedb.org/
# Here's how it works
First you install this nuget package `LiteDB.AutoApi` in your aspnet core application
Then create a model class you want to persist and expose as endpoint. It needs to inherit from LiteDbModel class. For example :
```c#
public class Vehicle : LiteDbModel
{
public string Model { get; set; }
public string Number { get; set; }
}
```
Now, in the Startup class, make the following change :
```c#
services.AddMvc()
.AddAutoApi("/vehicles");
```
And we are done. Note that you can add any number of AutoApis.
You have successfully created an api which can
- create/update a vehicle at `HTTPPOST` `/vehicles`
- retrieve a vehicle by id at `HTTPGET` `/vehicles/{vehicleId}`
- delete a vehicle at `HTTPDELETE` `/vehicles/{vehicleId}`
- list all vehicles at `HTTPGET` `/vehicles`