Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/v7e5/bareapi_asp_core

An example of a barebones ultra minimal todo list api using ASP.NET Core minimal webapi with simple cookie-based auth and zero dependencies.
https://github.com/v7e5/bareapi_asp_core

api asp-net-core aspnetcore barebones csharp dotnet dotnet-core minimal minimal-api rest-api sqlite sqlite3 todolist webapi

Last synced: about 1 month ago
JSON representation

An example of a barebones ultra minimal todo list api using ASP.NET Core minimal webapi with simple cookie-based auth and zero dependencies.

Awesome Lists containing this project

README

        

# Barebones Todo Minimal API - ASP.NET Core 8 (SQlite)

A sample minimal todo list api in C# with ASP.NET Core 8. This project uses
SQlite for database. Check out
[/v7e5/bareapi_asp_core_mssql](https://github.com/v7e5/bareapi_asp_core_mssql)
for a version that uses SQLServer/MSSQL.

## Features
+ Builds on the bare minimum `WebApplication.CreateEmptyBuilder`
+ Implements a simple cookie based user authentication / session using raw http
headers, backed by a session table in the database.
+ Avoids the complexity and ceremony of EFCore/ORMs in favor of raw sql queries/ADO.NET.
+ Uses sqlite for database. `Microsoft.Data.Sqlite` is the only required package dependency.
+ Implements keyset/cursor based pagination for the todo/list route

**Note**: I've used synchronous ADO.NET methods instead of
the preferred asynchronous variants for reasons detailed here.
https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/async

The shell scripts in misc are intended to be run in a zsh shell on linux. They
include convenience functions for building / executing as well as testing the
routes using curl. Feel free to ignore them if they don't match your use case.

## Endpoints

### Auth

#### login
POST: `/login`

Example request:
```shell
curl -vs -X POST \
--cookie ${COOKIE_FILE_PATH} \
--cookie-jar ${COOKIE_FILE_PATH} \
-H 'content-type: application/json' \
-H 'accept: application/json' \
--data-binary "$(cat <