24 lines
720 B
Forth
24 lines
720 B
Forth
namespace Shared
|
|
|
|
open System
|
|
|
|
type Counter = int
|
|
|
|
module Route =
|
|
let builder typeName methodName =
|
|
sprintf "/api/%s/%s" typeName methodName
|
|
|
|
module Feed =
|
|
type Item =
|
|
{ title : string
|
|
description : string
|
|
time : DateTimeOffset
|
|
link : string
|
|
source : string }
|
|
|
|
let sort (is : Item array) : Item array = Array.sortByDescending (fun (i : Item) -> i.time) is // newest articles first
|
|
let deduplicate (is : Item array) : Item array = Array.distinctBy hash is
|
|
let merge (is1 : Item array) (is2 : Item array) : Item array = Array.append is1 is2 |> sort |> deduplicate
|
|
|
|
type FeedReaderProtocol =
|
|
{ getItems : (int * int) -> Feed.Item array Async } |