Skip to content

Commit

Permalink
Merge server code into the monorepo (#1)
Browse files Browse the repository at this point in the history
* Move everything into client folder

* Set up project

* Add deploy script

* Read port from env

* Use buildpack instead of creating slugs from scratch

* Generate client functions in Elm and reorganize code

* Add swagger docs

* Integrate postgres db to store sheets

* Serve client/dist directory on root path

* Add yarn build step in client Makefile

* Remove CORS middleware

* Remove client start script

* Delete client README
  • Loading branch information
zcesur authored Aug 18, 2020
1 parent 21d038c commit 73b2908
Show file tree
Hide file tree
Showing 44 changed files with 398 additions and 112 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.stack-work/
*~
elm-stuff
repl-temp-*
dist
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build: client-build server-build

client-build:
(cd client ; make)

server-build:
stack build

install:
stack install
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: chordsheetify-exe
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/396fdb4f-dd5e-4ce4-b24f-5afe07d2cd60/deploy-status)](https://app.netlify.com/sites/gracious-poitras-4d06d1/deploys)
# chordsheetify
2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
75 changes: 75 additions & 0 deletions chordsheetify.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.33.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 0970cea64d239429c35b719155e4cf97e2fa8ed26542ff065ac48c7baf3b9248

name: chordsheetify
version: 0.1.0.0
description: Please see the README on GitHub at <https://github.com/zcesur/chordsheetify#readme>
homepage: https://github.com/zcesur/chordsheetify#readme
bug-reports: https://github.com/zcesur/chordsheetify/issues
author: Zafer Cesur
maintainer: [email protected]
copyright: 2020 Zafer Cesur
build-type: Simple
extra-source-files:
README.md

source-repository head
type: git
location: https://github.com/zcesur/chordsheetify

executable chordsheetify-exe
main-is: Main.hs
other-modules:
Api
App
Paths_chordsheetify
hs-source-dirs:
server
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, bytestring
, elm-bridge
, lens
, postgresql-simple
, resource-pool
, servant-elm
, servant-server
, servant-swagger
, servant-swagger-ui
, swagger2
, wai
, wai-app-static
, warp
default-language: Haskell2010

test-suite chordsheetify-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Paths_chordsheetify
hs-source-dirs:
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, bytestring
, chordsheetify
, elm-bridge
, lens
, postgresql-simple
, resource-pool
, servant-elm
, servant-server
, servant-swagger
, servant-swagger-ui
, swagger2
, wai
, wai-app-static
, warp
default-language: Haskell2010
19 changes: 19 additions & 0 deletions client/GenerateElm.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{-# LANGUAGE OverloadedStrings #-}

import Servant.Elm ( DefineElm(DefineElm)
, Proxy(Proxy)
, UrlPrefix(Static)
, defElmImports
, defElmOptions
, generateElmModuleWith
)
import Api

main :: IO ()
main = generateElmModuleWith
defElmOptions
["Api"]
defElmImports
"client/src"
[DefineElm (Proxy :: Proxy Sheet), DefineElm (Proxy :: Proxy SheetId)]
(Proxy :: Proxy RestApi)
9 changes: 9 additions & 0 deletions client/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
all: src/Api.elm build

src/Api.elm: GenerateElm.hs ../server/Api.hs
(cd ../ ; stack exec -- runhaskell -iserver client/GenerateElm.hs)

.PHONY: build
build:
yarn install
yarn build
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions package.json → client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"version": "0.1.0",
"main": "index.js",
"scripts": {
"start": "http-server dist",
"build": "webpack"
},
"repository": {
Expand All @@ -24,7 +23,6 @@
"elm": "^0.19.1-3",
"elm-webpack-loader": "^6.0.1",
"html-webpack-plugin": "^4.3.0",
"http-server": "^0.12.3",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions src/Api.elm → client/src/Api.elm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ getApiSheets toMsg =
, headers =
[]
, url =
Url.Builder.crossOrigin "https://chordsheetify.herokuapp.com"
Url.Builder.crossOrigin ""
[ "api"
, "sheets"
]
Expand Down Expand Up @@ -86,7 +86,7 @@ getApiSheetsById capture_id toMsg =
, headers =
[]
, url =
Url.Builder.crossOrigin "https://chordsheetify.herokuapp.com"
Url.Builder.crossOrigin ""
[ "api"
, "sheets"
, (capture_id |> String.fromInt)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 73b2908

Please sign in to comment.