Skip to content

Commit

Permalink
Modernise Stack (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
RawToast committed Oct 5, 2019
1 parent 0a67098 commit 00ed614
Show file tree
Hide file tree
Showing 9 changed files with 4,161 additions and 4,918 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ matrix:
script: ["yarn add coveralls", "yarn bsb -clean-world -make-world", "yarn ci"]

- language: scala
jdk: oraclejdk8
jdk: openjdk8
scala:
- 2.12.4
- 2.12.9
before_script:
- cd dokusho-server
script:
- sbt test
- sbt test
2 changes: 1 addition & 1 deletion dokusho-server/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "dokusho-server"

mainClass in(Compile, run) := Some("Main")

val SCALA_VERSION = "2.12.7"
val SCALA_VERSION = "2.12.9"

val CIRCE_VERSION = "0.10.1"
val HTTP4S_VERSION = "0.18.21"
Expand Down
5 changes: 5 additions & 0 deletions dokusho/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ yarn-debug.log*
yarn-error.log*

toolbox/
# Generated bucklescript js
*.bs.js
# Cache and runtime files
.cache/
dist/
11 changes: 8 additions & 3 deletions dokusho/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"type": "dev"
}
],
"package-specs": [
{
"module": "commonjs",
"in-source": true
}
],
"suffix": ".bs.js",
"namespace": true,
"bs-dependencies": [
"reason-react",
"@glennsl/bs-json",
Expand All @@ -26,8 +34,5 @@
"reason": {
"react-jsx": 2
},
"bsc-flags": [
"-bs-super-errors"
],
"refmt": 3
}
45 changes: 25 additions & 20 deletions dokusho/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,42 @@
"name": "dokusho",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "concurrently -c --kill-others 'npm:watch-html' 'npm:watch-reason'",
"build": "parcel build src/index.html --public-url /",
"clean": "rimraf .cache lib dist .merlin src/*.js",
"watch-html": "parcel src/index.html",
"watch-reason": "bsb -make-world -w",
"bsb": "bsb -make-world",
"test": "jest --env=jsdom --testMatch='**/test/*test.bs.js' --watch",
"coverage": "jest --env=node --testMatch='**/test/*test.bs.js' --coverage",
"ci": "yarn bsb && jest --env=jsdom --testMatch='**/test/*test.bs.js' --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"toolbox": "react-toolbox-themr"
},
"dependencies": {
"@glennsl/bs-json": "^1.1.3",
"@glennsl/bs-json": "^3.0.0",
"auth0-js": "^9.4.2",
"bs-fetch": "^0.2.1",
"bs-fetch": "^0.3.1",
"bs-webapi": "0.11.0",
"isomorphic-fetch": "^2.2.1",
"rationale": "^0.1.4",
"react": "^16.4.0",
"react-dom": "^16.4.0",
"reason-scripts": "0.8.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-toolbox-themr && react-scripts build",
"test": "react-scripts test --env=jsdom",
"coverage": "react-scripts test --env=jsdom --coverage",
"ci": "react-scripts test --env=jsdom --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"eject": "react-scripts eject",
"prepare": "npm link bs-platform",
"clean": "rm -rf lib && rm -rf node_modules && rm -rf build",
"toolbox": "react-toolbox-themr"
"react": "^16.4.2",
"react-dom": "^16.4.2"
},
"devDependencies": {
"@astrada/reason-react-toolbox": "^0.5.0",
"@glennsl/bs-jest": "^0.4.2",
"@astrada/reason-react-toolbox": "^0.6.0",
"@glennsl/bs-jest": "^0.4.7",
"bs-platform": "^4.0.18",
"bs-react-test-renderer": "^2.0.0",
"concurrently": "^4.1.0",
"parcel-bundler": "^1.11.0",
"react-toolbox-themr": "^1.0.2",
"reason-react": "^0.4.2"
"reason-react": "^0.5.3",
"rimraf": "^3.0.0"
},
"jest": {
"collectCoverageFrom": [
"src/app/**/*.{re}"
"**/app/*.bs.js"
]
}
}
63 changes: 32 additions & 31 deletions dokusho/src/App.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[%bs.raw {|require('../node_modules/auth0-js/build/auth0.js')|}];

[@bs.module]
external theme : ReactToolbox.ThemeProvider.theme = "./toolbox/theme";
external theme: ReactToolbox.ThemeProvider.theme = "./toolbox/theme";

open Dokusho;
open Types;
Expand All @@ -12,47 +12,48 @@ type action =
| ChangeRoute(Routes.route);

let reducer = (action, _state) =>
switch action {
| ChangeRoute(route) => ReasonReact.Update( route )
switch (action) {
| ChangeRoute(route) => ReasonReact.Update(route)
};

let component = ReasonReact.reducerComponent("App");

let mapUrlToRoute = (url: ReasonReact.Router.url) => {
switch url.path {
| ["callback"] => {
let token = Auth.handleAuth(url);
ReasonReact.Router.push("/");
Routes.Home(token);
}
| [] => {
Js.Console.log("Home");
let token = Auth.getAccessToken();
if(token == "" && !Auth.tokenStillValid()) Routes.NoAuth else Routes.Home(token);
}
| _ => {
let mapUrlToRoute = (url: ReasonReact.Router.url) =>
switch (url.path) {
| ["callback"] =>
let token = Auth.handleAuth(url);
ReasonReact.Router.push("/");
Routes.Home(token);
| [] =>
Js.Console.log("Home");
let token = Auth.getAccessToken();
if (token == "" && !Auth.tokenStillValid()) {
Routes.NoAuth;
} /* Routes.NotFound */
}
};
} else {
Routes.Home(token);
};
| _ => Routes.NoAuth /* Routes.NotFound */
};

let make = _children => {
...component,
reducer,
initialState: () => { Routes.NoAuth },
subscriptions: (self) => [
Sub(
() => ReasonReact.Router.watchUrl((url) => self.send(ChangeRoute(url |> mapUrlToRoute))),
ReasonReact.Router.unwatchUrl
)
],
initialState: () => Routes.NoAuth,
didMount: self => {
let watcherID = ReasonReact.Router.watchUrl(url => {
self.send(ChangeRoute(url |> mapUrlToRoute))
});
self.onUnmount(() => ReasonReact.Router.unwatchUrl(watcherID));
},
render: self =>
<ReactToolbox.ThemeProvider theme>
<div className="app">
(switch self.state {
| Routes.Home(token) => <Dokusho token=token/>
| Routes.NoAuth => <Login />
})
(
switch (self.state) {
| Routes.Home(token) => <Dokusho token />
| Routes.NoAuth => <Login />
}
)
</div>
</ReactToolbox.ThemeProvider>
</ReactToolbox.ThemeProvider>,
};
2 changes: 1 addition & 1 deletion dokusho/src/app/Entry.re
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let make = (~entry: entry, _children) => {
entry.kind
|> PageType.toString
|> ((str) => str ++ ": " ++ string_of_int(entry.value)
|> ReasonReact.stringToElement)
|> ReasonReact.string)
)
</div>
};
108 changes: 0 additions & 108 deletions dokusho/src/registerServiceWorker.js

This file was deleted.

Loading

0 comments on commit 00ed614

Please sign in to comment.