Skip to content

Instantly share code, notes, and snippets.

View terjokhin's full-sized avatar
🏠
Working from home

Alexey Terekhin terjokhin

🏠
Working from home
  • Netherlands, Utrecht
View GitHub Profile
def getBlocks: Route = (get & paging & sorting(sortByFieldMappings, Some("height")) & startEndDate) {
(o, l, field, so, start, end) =>
val sTs = start.getOrElse(0L)
val eTs = end.getOrElse(System.currentTimeMillis() + oneDayMillis)
val p = Paging(offset = o, limit = l)
val s = Sorting(sortBy = field, order = so)
val items = bs.getBlocks(p, s, sTs, eTs)
val count = bs.count(sTs, eTs)
val itemsResponse = (items, count).parMapN(ItemsResponse.apply)
itemsResponse
package org.daron.html
import cats.syntax.either._
import cats.syntax.flatMap._
import cats.syntax.functor._
import com.softwaremill.sttp.{SttpBackend, _}
import io.chrisdavenport.log4cats.Logger
trait HttpClient[F[_]] {
def getPageSource(uri: java.net.URI): F[String]
private def buildTelegramClient[F[_]: Execute: ConcurrentEffect](isProd: Boolean, token: String): Resource[F, TelegramClient[F]] =
buildHttp4sClient.map { httpsClient =>
TelegramClient.fromHttp4sClient[F](token)(
if (isProd) httpsClient
else ResponseLogger(true, true)(httpsClient)
)
}
object Loggers {
final val Welcome = "welcome"
final val Messages = "messages"
final val Users = "messages"
type MessagesLogging[F[_]] = Logging[F] @Id(Welcome)
type UsersLogging[F[_]] = Logging[F] @Id(Users)
type WelcomeLogging[F[_]] = Logging[F] @Id(Messages)