├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .ocamlformat ├── LICENSE ├── Makefile ├── README.md ├── app.ml ├── app.opam ├── dune ├── dune-project └── service.ml /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: Build and test 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | os: 13 | # Needs to have openssl installed 14 | # - macos-latest 15 | - ubuntu-latest 16 | ocaml-version: 17 | - 4.11.1 18 | - 4.10.1 19 | - 4.09.1 20 | - 4.08.1 21 | steps: 22 | - name: Checkout code 23 | uses: actions/checkout@v2 24 | - name: Retrieve opam cache 25 | uses: actions/cache@v2 26 | if: runner.os != 'Windows' 27 | id: cache-opam 28 | with: 29 | path: ~/.opam 30 | key: v1-${{ runner.os }}-opam-${{ matrix.ocaml-version }}-${{ hashFiles('*.opam.locked') }} 31 | restore-keys: | 32 | v2-${{ runner.os }}-opam-${{ matrix.ocaml-version }}- 33 | - name: Use OCaml ${{ matrix.ocaml-version }} 34 | uses: avsm/setup-ocaml@v1 35 | with: 36 | ocaml-version: ${{ matrix.ocaml-version }} 37 | - name: Install dependencies 38 | if: steps.cache-opam.outputs.cache-hit != 'true' 39 | run: | 40 | opam pin add sihl.0.1.3 git://github.com/oxidizing/sihl.git#master 41 | opam install . --deps-only --with-doc --with-test --locked --unlock-base 42 | - name: Recover from an Opam broken state 43 | if: steps.cache-opam.outputs.cache-hit == 'true' 44 | run: opam upgrade --fixup 45 | - name: Build 46 | run: make build 47 | - name: Run tests 48 | run: make test 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /_build/ 2 | /_opam/ 3 | .merlin 4 | -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxidizing/sihl-minimal-starter/50183e8615204cb2d39e56b2df9b8b4550af9595/.ocamlformat -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Josef Erben 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all test clean 2 | 3 | build: 4 | opam exec -- dune build 5 | 6 | clean: 7 | opam exec -- dune clean 8 | 9 | test: 10 | SIHL_ENV=test opam exec -- dune test 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Contributors][contributors-shield]][contributors-url] 2 | [![Forks][forks-shield]][forks-url] 3 | [![Stargazers][stars-shield]][stars-url] 4 | [![Issues][issues-shield]][issues-url] 5 | [![MIT License][license-shield]][license-url] 6 | 7 | 8 | # Deprecated 9 | 10 | This project is deprecated. If you want to start a new project use the [template](https://github.com/oxidizing/sihl/tree/master/template) as described [here](https://oxidizing.github.io/sihl/sihl/index.html#app-generation). 11 | If you want to browse an example Sihl project, check out [sihl-demo](https://github.com/oxidizing/sihl-demo). 12 | 13 | # Minimal Starter Project 14 | 15 | This is a simple starter project for the web framework [Sihl](https://github.com/oxidizing/sihl). Simply clone the repo and start building! 16 | 17 | ## Installation 18 | 19 | Clone the repository and make sure that you installed latest version of Sihl with `opam install sihl`. 20 | 21 | To automatically install all project dependencies you can also run `opam install . --deps-only --with-doc --with-test --locked --unlock-base`. 22 | 23 | [contributors-shield]: https://img.shields.io/github/contributors/oxidizing/sihl-minimal-starter.svg?style=flat-square 24 | [contributors-url]: https://github.com/oxidizing/sihl-minimal-starter/graphs/contributors 25 | [forks-shield]: https://img.shields.io/github/forks/oxidizing/sihl-minimal-starter.svg?style=flat-square 26 | [forks-url]: https://github.com/oxidizing/sihl-minimal-starter/network/members 27 | [stars-shield]: https://img.shields.io/github/stars/oxidizing/sihl-minimal-starter.svg?style=flat-square 28 | [stars-url]: https://github.com/oxidizing/sihl-minimal-starter/stargazers 29 | [issues-shield]: https://img.shields.io/github/issues/oxidizing/sihl-minimal-starter.svg?style=flat-square 30 | [issues-url]: https://github.com/oxidizing/sihl-minimal-starter/issues 31 | [license-shield]: https://img.shields.io/github/license/oxidizing/sihl-minimal-starter.svg?style=flat-square 32 | [license-url]: https://github.com/oxidizing/sihl-minimal-starter/blob/master/LICENSE.txt 33 | -------------------------------------------------------------------------------- /app.ml: -------------------------------------------------------------------------------- 1 | let services : (module Sihl.Core.Container.SERVICE) list = 2 | [ (module Service.WebServer) ] 3 | 4 | let hello_page = 5 | Sihl.Web.Route.get "/hello/" (fun _ -> 6 | Sihl.Web.Res.(html |> set_body "Hello!") |> Lwt.return) 7 | 8 | let hello_api = 9 | Sihl.Web.Route.get "/hello/" (fun _ -> 10 | Sihl.Web.Res.(json |> set_body {|{"msg":"Hello!"}|}) |> Lwt.return) 11 | 12 | let endpoints = [ ("/page", [ hello_page ], []); ("/api", [ hello_api ], []) ] 13 | 14 | module App = Sihl.App.Make (Service) 15 | 16 | let _ = App.(empty |> with_services services |> with_endpoints endpoints |> run) 17 | -------------------------------------------------------------------------------- /app.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "0.0.1" 4 | synopsis: "A minimal web app using Sihl" 5 | description: "A minimal web app using Sihl." 6 | maintainer: ["josef@oxidizing.io"] 7 | authors: ["Josef Erben"] 8 | license: "MIT" 9 | homepage: "https://github.com/oxidizing/sihl-minimal-starter" 10 | doc: "https://oxidizing.github.io/sihl/" 11 | bug-reports: "https://github.com/oxidizing/sihl-minimal-starter/issues" 12 | depends: [ 13 | "dune" {>= "2.4"} 14 | "ocaml" {>= "4.08.0"} 15 | "sihl" {>= "0.1.3"} 16 | ] 17 | build: [ 18 | ["dune" "subst"] {pinned} 19 | [ 20 | "dune" 21 | "build" 22 | "-p" 23 | name 24 | "-j" 25 | jobs 26 | "@install" 27 | "@runtest" {with-test} 28 | "@doc" {with-doc} 29 | ] 30 | ] 31 | dev-repo: "git+https://github.com/oxidizing/sihl-minimal-starter.git" 32 | -------------------------------------------------------------------------------- /dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name app) 3 | (libraries 4 | sihl)) 5 | -------------------------------------------------------------------------------- /dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.4) 2 | (generate_opam_files true) 3 | 4 | (name app) 5 | (version 0.0.1) 6 | 7 | (authors "Josef Erben") 8 | (source (github oxidizing/sihl-minimal-starter)) 9 | (license MIT) 10 | (maintainers "josef@oxidizing.io") 11 | (homepage "https://github.com/oxidizing/sihl-minimal-starter") 12 | (bug_reports "https://github.com/oxidizing/sihl-minimal-starter/issues") 13 | (documentation "https://oxidizing.github.io/sihl/") 14 | 15 | (package 16 | (name app) 17 | (synopsis "A minimal web app using Sihl") 18 | (description "A minimal web app using Sihl.") 19 | (depends 20 | ;; General system dependencies 21 | (dune (>= 2.4)) 22 | (ocaml (>= 4.08.0)) 23 | (sihl (>= 0.1.3)))) 24 | -------------------------------------------------------------------------------- /service.ml: -------------------------------------------------------------------------------- 1 | module Random = Sihl.Utils.Random.Service.Make () 2 | 3 | module Log = Sihl.Log.Service.Make () 4 | 5 | module Config = Sihl.Config.Service.Make (Log) 6 | module Db = Sihl.Data.Db.Service.Make (Config) (Log) 7 | module MigrationRepo = Sihl.Data.Migration.Service.Repo.MakeMariaDb (Db) 8 | 9 | module Cmd = Sihl.Cmd.Service.Make () 10 | 11 | module Migration = 12 | Sihl.Data.Migration.Service.Make (Log) (Cmd) (Db) (MigrationRepo) 13 | module WebServer = Sihl.Web.Server.Service.MakeOpium (Log) (Cmd) 14 | module Schedule = Sihl.Schedule.Service.Make (Log) 15 | module Seed = Sihl.Seed.Service.Make (Log) (Cmd) 16 | --------------------------------------------------------------------------------