-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add DartFrog JWT-Auth Example (#82)
* 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
Showing
10 changed files
with
759 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This project is licensed under the MIT License - Copyright Globe.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
linter: | ||
rules: | ||
file_names: false |
Oops, something went wrong.