This repository is the backend of simple-note that connects the database to the frontend
This is a Go API using Gorm as an ORM and Postgres as a database.
This API was developed by Daniel Ibanescu and Hamidreza Khoramrokh.
- Clone this repository.
- Install the dependencies using
go mod download
. - Set the environment variables in
.env.example
and rename it to.env
. - Run the server using
go run main.go
.
Name
(string): the name of the user.Email
(string): the email address of the user.Password
(string): the password of the user.Notebooks
(array of Notebook): the notebooks owned by the user.
UserID
(uint): the ID of the user who owns the notebook.Title
(string): the title of the notebook.Description
(string): the description of the notebook.Notes
(array of Note): the notes in the notebook.
NotebookID
(uint): the ID of the notebook that the note belongs to.Title
(string): the title of the note.Content
(string): the content of the note.
The migrateAll
function in main.go
is used to migrate the database. It migrates the User, Notebook, and Note models.
- POST
/auth/signup
: create a new user account. - POST
/auth/login
: log in to an existing user account.
- GET
/user
: get the authenticated user's information. - PUT
/user
: update the authenticated user's information. - DELETE
/user
: delete the authenticated user's account.
- GET
/notebooks
: get all notebooks owned by the authenticated user. - GET
/notebooks/all
: get all notebooks. - POST
/notebooks
: create a new notebook. - PUT
/notebooks
: update a notebook. - DELETE
/notebooks
: delete a notebook.
- GET
/notes/:id
: get a specific note. - GET
/notes/all
: get all notes in a notebook. - POST
/notes
: create a new note. - PUT
/notes/:id
: update a note. - DELETE
/notes/:id
: delete a note.
- GET
/
: a public endpoint that always returns success.
Note: All endpoints except for /public
require authentication using a JSON Web Token (JWT) in the Authorization
header.