servant-beam-realworld-example-app

由 Servant 和 Beam 支持的示例性全栈 Medium.com 克隆。「Exemplary fullstack Medium.com clone powered by Servant and Beam」

Github stars Tracking Chart

Servant & Beam RealWorld 示例应用程序

一个 Servant 和 Beam 代码库,包含遵循 RealWorld 规范和 API 的真实示例(CRUD,auth,高级模式等)。

演示 RealWorld

创建该代码库的目的是演示使用 Servant 和 Beam 构建的功能完善的全栈应用程序,其中包括 CRUD 操作、身份验证、路由、分页等。

我们已竭尽全力遵守Haskell社区风格指南和最佳实践。

有关如何与其他前端/后端一起使用的更多信息,请转到 RealWorld 存储库。

状态

但需要注意的是,授权头格式略有不同,所以这样做了:

┌─────────────────────────┬──────────┬──────────┐
│                         │ executed │   failed │
├─────────────────────────┼──────────┼──────────┤
│              iterations │        1 │        0 │
├─────────────────────────┼──────────┼──────────┤
│                requests │       31 │        0 │
├─────────────────────────┼──────────┼──────────┤
│            test-scripts │       46 │        0 │
├─────────────────────────┼──────────┼──────────┤
│      prerequest-scripts │       17 │        0 │
├─────────────────────────┼──────────┼──────────┤
│              assertions │      280 │        0 │
├─────────────────────────┴──────────┴──────────┤
│ total run duration: 18s                       │
├───────────────────────────────────────────────┤
│ total data received: 5.77KB (approx)          │
├───────────────────────────────────────────────┤
│ average response time: 25ms                   │
└───────────────────────────────────────────────┘

TODO

我对平均响应时间并不感到惊讶,这超过了 localhost ...使用非常空的表。

入门

使用 Nix 获取所需的所有 Haskell 软件包和应用程序依赖项。

$ nix-shell

从示例创建 .envrc 并允许内容

$ cp .envrc.example .envrc
$ direnv allow

设置数据库。

$ database/scripts/setup

运行测试套件。

$ cabal new-test

您可以使用 ghcid 在监视模式下运行这些命令:

$ dev/watch-tests

可能看起来像这样:


运行 app。

$ cabal new-run exe:realworld-conduit


(The first version translated by vz on 2020.08.14)

Overview

Name With Ownerbradparker/servant-beam-realworld-example-app
Primary LanguageHaskell
Program languageHaskell (Language Count: 4)
PlatformLinux, Mac, Windows
License:BSD 3-Clause "New" or "Revised" License
Release Count0
Created At2018-06-19 10:31:43
Pushed At2019-08-04 08:26:10
Last Commit At2019-03-31 11:21:13
Stargazers Count33
Watchers Count4
Fork Count6
Commits Count105
Has Issues Enabled
Issues Count2
Issue Open Count1
Pull Requests Count4
Pull Requests Open Count0
Pull Requests Close Count0
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

RealWorld Example App

Build Status

A Servant and Beam codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Demo RealWorld

This codebase was created to demonstrate a fully fledged fullstack application built with Servant and Beam including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Haskell community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

Status

With the caveat that the Authorization header format is slightly different, this is done:

┌─────────────────────────┬──────────┬──────────┐
│                         │ executed │   failed │
├─────────────────────────┼──────────┼──────────┤
│              iterations │        1 │        0 │
├─────────────────────────┼──────────┼──────────┤
│                requests │       31 │        0 │
├─────────────────────────┼──────────┼──────────┤
│            test-scripts │       46 │        0 │
├─────────────────────────┼──────────┼──────────┤
│      prerequest-scripts │       17 │        0 │
├─────────────────────────┼──────────┼──────────┤
│              assertions │      280 │        0 │
├─────────────────────────┴──────────┴──────────┤
│ total run duration: 18s                       │
├───────────────────────────────────────────────┤
│ total data received: 5.77KB (approx)          │
├───────────────────────────────────────────────┤
│ average response time: 25ms                   │
└───────────────────────────────────────────────┘

TODO

  • I'm not thrilled by that average response time, this is over localhost ... working with quite empty tables.

Getting started

  1. Use Nix to get all the Haskell package and application dependencies you need.
$ nix-shell
  1. Create .envrc from example and allow contents
$ cp .envrc.example .envrc
$ direnv allow
  1. Setup the database.
$ database/scripts/setup
  1. Run the test suite.
$ cabal new-test

You can run these in a watch mode using ghcid:

$ dev/watch-tests

Which might look something like this:

asciicast

  1. Run the app.
$ cabal new-run exe:realworld-conduit
To the top