Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ludwigsw committed May 8, 2024
0 parents commit 82dbfa7
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test

on:
push:
branches:
- master
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
with:
otp-version: "26.0.2"
gleam-version: "1.0.0"
rebar3-version: "3"
# elixir-version: "1.15.4"
- run: gleam deps download
- run: gleam test
- run: gleam format --check src test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.beam
*.ez
/build
erl_crash.dump
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# apero_webapp

[![Package Version](https://img.shields.io/hexpm/v/apero_webapp)](https://hex.pm/packages/apero_webapp)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/apero_webapp/)

```sh
gleam add apero_webapp
```
```gleam
import apero_webapp
pub fn main() {
// TODO: An example of the project in use
}
```

Further documentation can be found at <https://hexdocs.pm/apero_webapp>.

## Development

```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```
13 changes: 13 additions & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "app"
version = "1.0.0"
description = "A Wisp example"
gleam = ">= 0.32.0"

[dependencies]
gleam_stdlib = "~> 0.30"
wisp = { path = "../.." }
gleam_erlang = "~> 0.23"
mist = "~> 0.14"

[dev-dependencies]
gleeunit = "~> 1.0"
5 changes: 5 additions & 0 deletions src/apero_webapp.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import gleam/io

pub fn main() {
io.println("Hello from apero_webapp!")
}
25 changes: 25 additions & 0 deletions src/app.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import gleam/erlang/process
import mist
import wisp
import app/router

pub fn main() {
// This sets the logger to print INFO level logs, and other sensible defaults
// for a web application.
wisp.configure_logger()

// Here we generate a secret key, but in a real application you would want to
// load this from somewhere so that it is not regenerated on every restart.
let secret_key_base = wisp.random_string(64)

// Start the Mist web server.
let assert Ok(_) =
wisp.mist_handler(router.handle_request, secret_key_base)
|> mist.new
|> mist.port(8000)
|> mist.start_http

// The web server runs in new Erlang process, so put this one to sleep while
// it works concurrently.
process.sleep_forever()
}
Empty file added src/app/router.gleam
Empty file.
12 changes: 12 additions & 0 deletions test/apero_webapp_test.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import gleeunit
import gleeunit/should

pub fn main() {
gleeunit.main()
}

// gleeunit test functions end in `_test`
pub fn hello_world_test() {
1
|> should.equal(1)
}

0 comments on commit 82dbfa7

Please sign in to comment.