-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c8909ab
Showing
34 changed files
with
7,082 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
API_ENDPOINT=https://conduit.productionready.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/bower_components/ | ||
/node_modules/ | ||
/.pulp-cache/ | ||
/output/ | ||
/generated-docs/ | ||
/.psc-package/ | ||
/.psc* | ||
/.purs* | ||
/.psa* | ||
/dist/ | ||
/.cache/ | ||
/.spago/ | ||
/*.log | ||
/.parcel-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"purescript.addNpmPath": true, | ||
"purescript.addPscPackageSources": true, | ||
"purescript.addSpagoSources": true, | ||
"purescript.editorMode": true, | ||
"purescript.buildCommand": "spago build --purs-args \"--json-errors\"", | ||
"[purescript]": { | ||
"editor.formatOnSave": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Jonas Buntinx | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Real World PureScript React |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Conduit</title> | ||
<link | ||
href="//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<link | ||
href="//fonts.googleapis.com/css?family=Titillium+Web:700|Source+Serif+Pro:400,700|Merriweather+Sans:400,700|Source+Sans+Pro:400,300,600,700,300italic,400italic,600italic,700italic" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<link | ||
href="//demo.productionready.io/main.css" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
</head> | ||
|
||
<body> | ||
<div id="conduit"></div> | ||
<script src="./index.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("~/output/Main").main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "purescript-react-realworld", | ||
"version": "1.0.0", | ||
"description": "A real-world application demonstrating PureScript and React", | ||
"keywords": [ | ||
"Purescript", | ||
"React", | ||
"RealWorld" | ||
], | ||
"author": "Jonas Buntinx", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "spago build", | ||
"bundle": "yarn build && parcel build index.html", | ||
"clean": "rm -Rf .cache dist output", | ||
"dev-server": "parcel serve --no-source-maps index.html", | ||
"id": "pscid", | ||
"pscid:build": "yarn build", | ||
"postinstall": "spago install", | ||
"rebuild": "yarn clean && yarn build", | ||
"rebundle": "yarn clean && yarn bundle", | ||
"serve": "yarn build && yarn dev-server", | ||
"test": "spago test" | ||
}, | ||
"devDependencies": { | ||
"parcel": "^1.12.4", | ||
"pscid": "^2.9.3", | ||
"purescript": "^0.13.8", | ||
"purescript-psa": "^0.7.3", | ||
"purty": "^6.2.0", | ||
"spago": "^0.15.3" | ||
}, | ||
"dependencies": { | ||
"moment": "^2.27.0", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
{- | ||
Welcome to your new Dhall package-set! | ||
Below are instructions for how to edit this file for most use | ||
cases, so that you don't need to know Dhall to use it. | ||
## Warning: Don't Move This Top-Level Comment! | ||
Due to how `dhall format` currently works, this comment's | ||
instructions cannot appear near corresponding sections below | ||
because `dhall format` will delete the comment. However, | ||
it will not delete a top-level comment like this one. | ||
## Use Cases | ||
Most will want to do one or both of these options: | ||
1. Override/Patch a package's dependency | ||
2. Add a package not already in the default package set | ||
This file will continue to work whether you use one or both options. | ||
Instructions for each option are explained below. | ||
### Overriding/Patching a package | ||
Purpose: | ||
- Change a package's dependency to a newer/older release than the | ||
default package set's release | ||
- Use your own modified version of some dependency that may | ||
include new API, changed API, removed API by | ||
using your custom git repo of the library rather than | ||
the package set's repo | ||
Syntax: | ||
Replace the overrides' "{=}" (an empty record) with the following idea | ||
The "//" or "⫽" means "merge these two records and | ||
when they have the same value, use the one on the right:" | ||
------------------------------- | ||
let overrides = | ||
{ packageName = | ||
upstream.packageName // { updateEntity1 = "new value", updateEntity2 = "new value" } | ||
, packageName = | ||
upstream.packageName // { version = "v4.0.0" } | ||
, packageName = | ||
upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" } | ||
} | ||
------------------------------- | ||
Example: | ||
------------------------------- | ||
let overrides = | ||
{ halogen = | ||
upstream.halogen // { version = "master" } | ||
, halogen-vdom = | ||
upstream.halogen-vdom // { version = "v4.0.0" } | ||
} | ||
------------------------------- | ||
### Additions | ||
Purpose: | ||
- Add packages that aren't already included in the default package set | ||
Syntax: | ||
Replace the additions' "{=}" (an empty record) with the following idea: | ||
------------------------------- | ||
let additions = | ||
{ package-name = | ||
{ dependencies = | ||
[ "dependency1" | ||
, "dependency2" | ||
] | ||
, repo = | ||
"https://example.com/path/to/git/repo.git" | ||
, version = | ||
"tag ('v4.0.0') or branch ('master')" | ||
} | ||
, package-name = | ||
{ dependencies = | ||
[ "dependency1" | ||
, "dependency2" | ||
] | ||
, repo = | ||
"https://example.com/path/to/git/repo.git" | ||
, version = | ||
"tag ('v4.0.0') or branch ('master')" | ||
} | ||
, etc. | ||
} | ||
------------------------------- | ||
Example: | ||
------------------------------- | ||
let additions = | ||
{ benchotron = | ||
{ dependencies = | ||
[ "arrays" | ||
, "exists" | ||
, "profunctor" | ||
, "strings" | ||
, "quickcheck" | ||
, "lcg" | ||
, "transformers" | ||
, "foldable-traversable" | ||
, "exceptions" | ||
, "node-fs" | ||
, "node-buffer" | ||
, "node-readline" | ||
, "datetime" | ||
, "now" | ||
] | ||
, repo = | ||
"https://github.com/hdgarrood/purescript-benchotron.git" | ||
, version = | ||
"v7.0.0" | ||
} | ||
} | ||
------------------------------- | ||
-} | ||
|
||
|
||
let upstream = | ||
https://github.com/purescript/package-sets/releases/download/psc-0.13.8/packages.dhall sha256:0e95ec11604dc8afc1b129c4d405dcc17290ce56d7d0665a0ff15617e32bbf03 | ||
|
||
let overrides = | ||
{ simple-json = | ||
upstream.simple-json | ||
// { repo = "https://github.com/robertdp/purescript-simple-json.git" | ||
, version = "v7.0.1" | ||
} | ||
} | ||
|
||
let additions = | ||
{ apiary = | ||
{ dependencies = | ||
[ "media-types" | ||
, "milkis" | ||
, "simple-json" | ||
] | ||
, repo = "https://github.com/robertdp/purescript-apiary" | ||
, version = "v0.1.0" | ||
} | ||
, react-basic-hooks-store = | ||
{ dependencies = | ||
[ "avar" | ||
, "console" | ||
, "prelude" | ||
, "react-basic-hooks" | ||
] | ||
, repo = "https://github.com/robertdp/purescript-react-basic-hooks-store" | ||
, version = "v0.2.2" | ||
} | ||
, wire = | ||
{ dependencies = | ||
[ "arrays" | ||
, "filterable" | ||
, "foreign-object" | ||
, "free" | ||
, "freet" | ||
, "react-basic-hooks" | ||
, "refs" | ||
, "unsafe-reference" | ||
] | ||
, repo = "https://github.com/robertdp/purescript-wire" | ||
, version = "v0.4.1" | ||
} | ||
} | ||
|
||
in upstream // overrides // additions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ name = "purescript-react-realword" | ||
, dependencies = | ||
[ "apiary" | ||
, "console" | ||
, "effect" | ||
, "foreign-generic" | ||
, "heterogeneous" | ||
, "js-timers" | ||
, "profunctor-lenses" | ||
, "react-basic" | ||
, "react-basic-hooks" | ||
, "react-basic-hooks-store" | ||
, "routing" | ||
, "routing-duplex" | ||
, "web-uievents" | ||
, "wire" | ||
] | ||
, packages = ./packages.dhall | ||
, sources = [ "src/**/*.purs", "test/**/*.purs" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Conduit.Api.User where | ||
|
||
import Apiary.Media (JSON) | ||
import Apiary.Route (POST) | ||
import Data.Maybe (Maybe) | ||
|
||
type Login | ||
= POST "/api/users/login" | ||
{ body :: | ||
JSON | ||
{ user :: | ||
{ email :: String | ||
, password :: String | ||
} | ||
} | ||
, response :: | ||
{ ok :: | ||
JSON | ||
{ user :: User () | ||
} | ||
} | ||
} | ||
|
||
-- | Types | ||
type User r | ||
= Profile | ||
( token :: Token | ||
| r | ||
) | ||
|
||
type Profile r | ||
= { username :: String | ||
, bio :: Maybe String | ||
, image :: Maybe String | ||
| r | ||
} | ||
|
||
type Token | ||
= String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Conduit.Api.Utils where | ||
|
||
import Prelude | ||
import Apiary.Client (Error, makeRequest) as Apiary | ||
import Apiary.Client.Request (class BuildRequest) as Apiary | ||
import Apiary.Client.Response (class DecodeResponse) as Apiary | ||
import Conduit.Data.Config as Config | ||
import Data.Either (Either) | ||
import Effect.Aff.Class (class MonadAff, liftAff) | ||
import Milkis as Milkis | ||
|
||
makeRequest :: | ||
forall m route path query body rep response. | ||
MonadAff m => | ||
Apiary.BuildRequest route path query body rep => | ||
Apiary.DecodeResponse rep response => | ||
route -> | ||
path -> | ||
query -> | ||
body -> | ||
m (Either Apiary.Error response) | ||
makeRequest route path query body = liftAff $ Apiary.makeRequest route addBaseUrl path query body | ||
|
||
-- | Helpers | ||
addBaseUrl :: forall r. { url :: Milkis.URL | r } -> { url :: Milkis.URL | r } | ||
addBaseUrl request@{ url: Milkis.URL url } = request { url = Milkis.URL (Config.apiEndpoint <> url) } |
Oops, something went wrong.