Skip to content

Commit

Permalink
feat: Add DartFrog JWT-Auth Example (#82)
Browse files Browse the repository at this point in the history
* move all templates to public repository

* update templates

* restructure folders

* fix docker file

* fix folders

* change all default to true

* add more to the template

* remove other templates

* wip

* simple dart frog template

* add tests

* wip

* resolve linter issues

* fix analysis issue

* rework simple dart frog template

* rework simple dart-frog example

* improve simple dart-frog example

* tiny fix

* misc

* specify collection package version

* rename template

* restructure code

* wip

* add dart frog jwt auth example

* remove unused import

* remove unnecessary files

* update template doc

* simplify dartfrog jwt auth

* remove unused packages

* update docs

* _

* _

* _

* _

* remove unused packages

* _

* _

* _

* _

---------

Co-authored-by: Majid <[email protected]>
  • Loading branch information
codekeyz and mhadaily committed May 22, 2024
1 parent a6d442e commit 18f6986
Show file tree
Hide file tree
Showing 10 changed files with 759 additions and 0 deletions.
14 changes: 14 additions & 0 deletions templates/dartfrog_jwt_auth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
node_modules/
npm-debug.log
dist/
.vscode/
.wrangler
.nvim.lua
.idea
*.iml
.dart_tool
.fvm
.dart_frog

.env
1 change: 1 addition & 0 deletions templates/dartfrog_jwt_auth/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This project is licensed under the MIT License - Copyright Globe.dev
68 changes: 68 additions & 0 deletions templates/dartfrog_jwt_auth/TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: Dart-Frog JWT Auth
description: Building a simple Dart-Frog Backend with JWT Auth
tags: ["dart-frog", "jwt", "authentication"]
username: Invertase
---

# Dart-Frog JWT Auth

## Overview

Get started with Dart-Frog JWT Authentication for your backend. Register user with Username/Password & issue JWT tokens for accessing protected routes.

### Getting Started

#### Bootstrap

Initialize your project using the command below

```shell
$ globe create -t dartfrog_jwt_auth
```

> For local development, create a `.env` file in the root of your project and provide `JWT_SECRET_KEY` environment variable.
#### Start Server

```shell
$ dart_frog dev --port=8080
```

### REST Endpoints

- Register User

```shell
curl -X POST -H "Content-Type: application/json" -d '{"username": "john", "password": "password123"}' http://localhost:8080/register
```

```
User registered
```

- Login User

```shell
curl -X POST -H "Content-Type: application/json" -d '{"username": "john", "password": "password123"}' http://localhost:8080/login
```

```json
{
"token": "<your-jwt-token>"
}
```

- Get Current User

```shell
curl -H "Authorization: Bearer <your-jwt-token>" http://localhost:8080/me
```

```json
{
"id": "user_id",
"username": "john",
"createdAt": "2024-05-07T12:30:45Z"
}
```
5 changes: 5 additions & 0 deletions templates/dartfrog_jwt_auth/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:lints/recommended.yaml

linter:
rules:
file_names: false
Loading

0 comments on commit 18f6986

Please sign in to comment.