Skip to content

Commit

Permalink
docs: add doc comments and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
brettkolodny committed Mar 17, 2024
1 parent 157e1c2 commit b4e0fd4
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.ez
build
erl_crash.dump
src/example.gleam
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
# gwt

Encode and decode JWTs.

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

## Quick start
## Quickstart

```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```gleam
import gwt.{type Jwt, type Verified, type Unverified}
pub fn main() {
let jwt =
gwt.new()
|> gwt.set_subject("1234567890")
|> gwt.set_audience("0987654321")
|> gwt.set_not_before(1_704_043_160)
|> gwt.set_expiration(1_704_046_160)
|> gwt.set_jwt_id("2468")
let jwt_without_signature = gwt.to_string(jwt)
let jwt_with_signature = gwt.to_signed_string(jwt, gwt.HS256, "lucy")
let assert Ok(unverified_jwt) =
jwt_without_signature
|> gwt.from_string()
let assert Ok(verified_jwt) =
jwt_with_signature
|>gwt.from_signed_string("lucy")
}
```

## Installation

If available on Hex this package can be added to your Gleam project:

```sh
gleam add gwt
gleam add gwt
```

and its documentation can be found at <https://hexdocs.pm/gwt>.
The documentation can be found at <https://hexdocs.pm/gwt>.
Loading

0 comments on commit b4e0fd4

Please sign in to comment.