modulepackage
0.0.0-20210516165035-e963ebd9a59a
Repository: https://github.com/aloiscrr/jwt-api-notes.git
Documentation: pkg.go.dev
# README
Notes API
API to save user notes, implementing JWT for auth and MongoDB as database.
Run Locally
-
Install both:
You will need to have MongoDB running on port 27017.
-
Clone the project:
git clone https://github.com/AloisCRR/jwt-api-notes.git
-
Go to the project directory:
cd jwt-api-notes
-
Install dependencies:
go mod tidy
-
Start the server:
go run main.go
REST API will run in http://localhost:8080.
API Reference
Note
Signup or register
POST /signup
Body | Type | Description |
---|---|---|
email | string | Required. User email address |
password | string | Required. Account password |
Response | Type | Description |
---|---|---|
message | string | API message |
status | number | HTTP status code |
token | string | Auth token to access protected routes |
Sign in or login
POST /login
Body | Type | Description |
---|---|---|
email | string | Required. User email address |
password | string | Required. Account password |
Response | Type | Description |
---|---|---|
message | string | API message |
status | number | HTTP status code |
token | Bearer token | Auth token to access protected routes |
Note creation
POST /notes
Headers | Type | Description |
---|---|---|
Authentication | Bearer token | Required. Jwt given on sign in or sign up |
Body | Type | Description |
---|---|---|
title | string | Required. Note title |
content | string | Note content |
Response | Type | Description |
---|---|---|
message | string | API message |
status | number | HTTP status code |
Get all notes
GET /notes
Headers | Type | Description |
---|---|---|
Authentication | Bearer token | Required. Jwt given on sign in or sign up |
Response | Type | Description |
---|---|---|
data | Note[] | API message |
message | string | API message |
status | number | HTTP status code |
Note update
PUT /notes/${id}
Parameter | Type | Description |
---|---|---|
id | string | Required. Note ID |
Headers | Type | Description |
---|---|---|
Authentication | Bearer token | Required. Jwt given on sign in or sign up |
Response | Type | Description |
---|---|---|
message | string | API message |
status | number | HTTP status code |
Get single note
GET /notes/${id}
Parameter | Type | Description |
---|---|---|
id | string | Required. Note ID |
Headers | Type | Description |
---|---|---|
Authentication | Bearer token | Required. Jwt given on sign in or sign up |
Response | Type | Description |
---|---|---|
data | Note | API message |
message | string | API message |
status | number | HTTP status code |
Delete note
DELETE /notes/${id}
Parameter | Type | Description |
---|---|---|
id | string | Required. Note ID |
Headers | Type | Description |
---|---|---|
Authentication | Bearer token | Required. Jwt given on sign in or sign up |
Response | Type | Description |
---|---|---|
message | string | API message |
status | number | HTTP status code |
Screenshots
No token provided
Basic input validation
Sign up or register
Sign in or login
Note creation
All notes
Note update
Get single note
Delete note
Tech Stack
Name | Description |
---|---|
MongoDB | Database |
Gin | HTTP Server |
jwt-go | Library to generate, parse, validate and more JWTs |
validator | Input validation |
Bcrypt | Algorithm used to hash passwords. |
Roadmap
- App functionality
- Testing
- Hosting, domain, etc.
- CI/CD
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author