gothinkster / realworld

"The mother of all demo apps" — Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more
https://realworld-docs.netlify.app/
MIT License
80.58k stars 7.34k forks source link

🗄🔧 Haskell / Yesod #202

Closed tzemanovic closed 6 years ago

tzemanovic commented 6 years ago

Current Status

Codebase in progress: https://github.com/tzemanovic/haskell-yesod-realworld-example-app

Todo:

tzemanovic commented 6 years ago

Hi, I've got this implementation ready. Please, let me know what to do for the next step.

anishkny commented 6 years ago

@tzemanovic this looks amazing! 🙌 a few suggestions:

  1. Could you summarize "How it works" in the README itself (its okay if not the whole blog post, at least some key information)?
  2. Could you run Postman API tests against your stack to ensure they work, and maybe even add to Travis YML file?

Great work!!!

tzemanovic commented 6 years ago

Hi Anish, thank you!

  1. I've had a link to a blog post with overview of the project, but it wasn't very visible, so I've updated it.
  2. Thanks for fixing the tests in #255, I've ran them and all are passing except for the timestamp tests such as:

tests['Article\\'s \"createdAt\" property is an ISO 8601 timestamp'] = new Date(article.createdAt).toISOString() === article.createdAt;",

SQLite seems to be using 3 more decimals for microseconds, which get lost in the new Date(t).toISOString() conversion, but this is a valid ISO 8601 date.

tzemanovic commented 6 years ago

With the updates from #255 and #260, this is passing the postman tests now:

Conduit

❏ Auth
↳ Register
  POST https://localhost:3443/api/users [200 OK, 733B, 79ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property

↳ Login
  POST https://localhost:3443/api/users/login [200 OK, 733B, 33ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property

↳ Login and Remember Token
  POST https://localhost:3443/api/users/login [200 OK, 733B, 31ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property
  ✓  Global variable "token" has been set

↳ Current User
  GET https://localhost:3443/api/user [200 OK, 733B, 4ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property

↳ Update User
  PUT https://localhost:3443/api/user [200 OK, 732B, 6ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property

❏ Articles
↳ All Articles
  GET https://localhost:3443/api/articles [200 OK, 436B, 4ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles by Author
  GET https://localhost:3443/api/articles?author=johnjacob [200 OK, 436B, 4ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles Favorited by Username
  GET https://localhost:3443/api/articles?favorited=jane [200 OK, 436B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles by Tag
  GET https://localhost:3443/api/articles?tag=dragons [200 OK, 436B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

❏ Articles, Favorite, Comments
↳ Create Article
  POST https://localhost:3443/api/articles [200 OK, 834B, 11ms]
  ✓  Response contains "article" property
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Feed
  GET https://localhost:3443/api/articles/feed [200 OK, 436B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ All Articles
  GET https://localhost:3443/api/articles [200 OK, 855B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ All Articles with auth
  GET https://localhost:3443/api/articles [200 OK, 855B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Articles by Author
  GET https://localhost:3443/api/articles?author=tzemanovic [200 OK, 855B, 5ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Articles by Author with auth
  GET https://localhost:3443/api/articles?author=tzemanovic [200 OK, 855B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Articles Favorited by Username
  GET https://localhost:3443/api/articles?favorited=jane [200 OK, 436B, 2ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Articles Favorited by Username with auth
  GET https://localhost:3443/api/articles?favorited=jane [200 OK, 436B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  articlesCount is 0 when feed is empty

↳ Single Article by slug
  GET https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b [200 OK, 834B, 3ms]
  ✓  Response contains "article" property
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Articles by Tag
  GET https://localhost:3443/api/articles?tag=dragons [200 OK, 855B, 4ms]
  ✓  Response code is 200 OK
  ✓  Response contains "articles" property
  ✓  Response contains "articlesCount" property
  ✓  articlesCount is an integer
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Update Article
  PUT https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b [200 OK, 833B, 4ms]
  ✓  Response contains "article" property
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

↳ Favorite Article
  POST https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b/favorite [200 OK, 832B, 4ms]
  ✓  Response contains "article" property
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article's 'favorited' property is true
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer
  ✓  Article's 'favoritesCount' property is greater than 0

↳ Unfavorite Article
  DELETE https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b/favorite [200 OK, 833B, 3ms]
  ✓  Response contains "article" property
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  ✓  Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  ✓  Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer
  ✓  Article's "favorited" property is true

↳ Create Comment for Article
  POST https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b/comments [200 OK, 665B, 4ms]
  ✓  Response contains "comment" property
  ✓  Comment has "id" property
  ✓  Comment has "body" property
  ✓  Comment has "createdAt" property
  ✓  "createdAt" property is an ISO 8601 timestamp
  ✓  Comment has "updatedAt" property
  ✓  "updatedAt" property is an ISO 8601 timestamp
  ✓  Comment has "author" property

↳ All Comments for Article
  GET https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b/comments [200 OK, 668B, 2ms]
  ✓  Response code is 200 OK
  ✓  Response contains "comments" property
  ✓  Comment has "id" property
  ✓  Comment has "body" property
  ✓  Comment has "createdAt" property
  ✓  "createdAt" property is an ISO 8601 timestamp
  ✓  Comment has "updatedAt" property
  ✓  "updatedAt" property is an ISO 8601 timestamp
  ✓  Comment has "author" property

↳ Delete Comment for Article
  DELETE https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b/comments/1 [200 OK, 407B, 2ms]

↳ Delete Article
  DELETE https://localhost:3443/api/articles/how-to-train-your-dragon-toll6b [200 OK, 407B, 3ms]

❏ Profiles
↳ Register Celeb
  POST https://localhost:3443/api/users [200 OK, 745B, 31ms]
  ✓  Response contains "user" property
  ✓  User has "email" property
  ✓  User has "username" property
  ✓  User has "bio" property
  ✓  User has "image" property
  ✓  User has "token" property

↳ Profile
  GET https://localhost:3443/api/profiles/celeb_tzemanovic [200 OK, 541B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "profile" property
  ✓  Profile has "username" property
  ✓  Profile has "bio" property
  ✓  Profile has "image" property
  ✓  Profile has "following" property

↳ Follow Profile
  POST https://localhost:3443/api/profiles/celeb_tzemanovic/follow [200 OK, 540B, 4ms]
  ✓  Response code is 200 OK
  ✓  Response contains "profile" property
  ✓  Profile has "username" property
  ✓  Profile has "bio" property
  ✓  Profile has "image" property
  ✓  Profile has "following" property
  ✓  Profile's "following" property is true

↳ Unfollow Profile
  DELETE https://localhost:3443/api/profiles/celeb_tzemanovic/follow [200 OK, 541B, 3ms]
  ✓  Response code is 200 OK
  ✓  Response contains "profile" property
  ✓  Profile has "username" property
  ✓  Profile has "bio" property
  ✓  Profile has "image" property
  ✓  Profile has "following" property
  ✓  Profile's "following" property is false

❏ Tags
↳ All Tags
  GET https://localhost:3443/api/tags [200 OK, 434B, 2ms]
  ✓  Response code is 200 OK
  ✓  Response contains "tags" property
  ✓  "tags" property returned as array

┌─────────────────────────┬──────────┬──────────┐
│                         │ executed │   failed │
├─────────────────────────┼──────────┼──────────┤
│              iterations │        1 │        0 │
├─────────────────────────┼──────────┼──────────┤
│                requests │       31 │        0 │
├─────────────────────────┼──────────┼──────────┤
│            test-scripts │       46 │        0 │
├─────────────────────────┼──────────┼──────────┤
│      prerequest-scripts │       17 │        0 │
├─────────────────────────┼──────────┼──────────┤
│              assertions │      280 │        0 │
├─────────────────────────┴──────────┴──────────┤
│ total run duration: 1024ms                    │
├───────────────────────────────────────────────┤
│ total data received: 7.43KB (approx)          │
├───────────────────────────────────────────────┤
│ average response time: 8ms                    │
└───────────────────────────────────────────────┘
anishkny commented 6 years ago

Fantastic!