[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
388 lines (358 loc) · 10.4 KB

README.md

File metadata and controls

388 lines (358 loc) · 10.4 KB

HttpNotesApiKtor

LinkedIn Badge

Notes API That's Built With Ktor to keep and organize user's notes. This repository contains a Notes Api This is an educational API.Use and run this API to learn more about API design and best practices you must follow.That's built with Ktor to keep and organize users's notes , That's implements Pagination,Coroutines,JWT,clean architecture,Koin,Exposed,jackson,etc... using kotlin language with ktor framework. You can find postman document here -> UserEndpoint NoteEndpoint

Table Of Content

Endpoints

User endpoint

Introduction

In this part you will find all operators you can make such as

  • Login With Email And Password
  • Register With Email And Password

Operators

POST Login
 http://127.0.0.1:9090/user/login

Body raw (json)

{
  "email": "adelayman0000@gmail.com",
  "password": "123456"
}

Response

{
  "status": true,
  "data": {
    "userID": "1",
    "userToken": "TOKEN",
    "userName": "Adel Ayman",
    "email": "adelayman0000@gmail.com"
  },
  "message": "Login done successfully"
}

POST Register
 http://127.0.0.1:9090/user/register

Body raw (json)

{
  "name": "Adel Ayman",
  "email": "adelayman0000@gmail.com",
  "password": "123456"
}

Response

{
  "status": true,
  "data": {
    "userID": "2",
    "userToken": "TOKEN",
    "userName": "Adel Ayman",
    "email": "adelayman0000@gmail.com"
  },
  "message": "Registration done successfully"
}

Notes endpoint

Introduction

In this part you will find all operators you can make such as

  • Save New Note
  • Delete a Saved Note
  • Update Previously Saved Note
  • Get User Notes
  • Get Note Details
  • Search In Notes

Operators

POST AddNote
 http://127.0.0.1:9090/notes

Request Headers

Authorization:Bearer TOKEN

Body raw (json)

{
  "title": "hello3!!!",
  "description": "Welcome to us again again!",
  "subtitle": "anything",
  "color": 2656,
  "webLink": "https://github.com/adelayman1",
  "image": "https://avatars.githubusercontent.com/u/85571327?s=400&u=b39f4f0b0d503f5826f4d74fa6f951aee05703b6&v=4"
}

Response

{
    "status": true,
    "data": {
        "noteId": "8",
        "email": "adelayman0000@gmail.com",
        "title": "hello3!!!",
        "subtitle": "anything",
        "description": "Welcome to us again again!",
        "date": "Thursday, 08 December 2022 18:05",
        "image": "https://avatars.githubusercontent.com/u/85571327?s=400&u=b39f4f0b0d503f5826f4d74fa6f951aee05703b6&v=4",
        "webLink": "https://github.com/adelayman1",
        "color": 2656
    },
    "message": "Note has added successfully"
}

DEL DeleteNote
 http://127.0.0.1:9090/notes/{note_id}

Request Headers

Authorization:Bearer TOKEN

Response

{
  "status": true,
  "data": null,
  "message": "Note has deleted successfully"
}

GET GetAllNotes
 http://127.0.0.1:9090/notes

Request Headers

Authorization:Bearer TOKEN

- limit(*optional)
- offset(*optional(starts from 0))

Response

{
  "status": true,
  "data": [
    {
      "noteId": "1",
      "email": "email",
      "title": "testing note",
      "subtitle": "1sss",
      "description": "postman Descreptionaaaaaaaaankjdkjkjk adel ayman any thing new word",
      "date": "Tuesday, 06 December 2022 14:37",
      "image": "https://avatars.githubusercontent.com/u/85571327?s=400&u=b39f4f0b0d503f5826f4d74fa6f951aee05703b6&v=4",
      "webLink": "https://github.com/adelayman1/QuranAppCoroutine",
      "color": 5
    },.........
  ],
  "message": "Notes have got successfully"
}

GET GetNoteDetails
 http://127.0.0.1:9090/notes/{note_id}

Request Headers

Authorization:Bearer TOKEN

Response

{
  "status": true,
  "data": {
    "noteId": "5",
    "email": "EMAIL",
    "title": "details as Lorem ipsum",
    "subtitle": "Lorem ipsum",
    "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Amet commodo nulla facilisi nullam vehicula ipsum a arcu. Viverra mauris in aliquam sem fringilla ut morbi. Nisi vitae suscipit tellus mauris a diam maecenas sed enim. Ornare arcu odio ut sem nulla pharetra diam. Sit amet commodo nulla facilisi nullam vehicula ipsum. Consectetur",
    "date": "Tuesday, 06 December 2022 14:41",
    "image": null,
    "webLink": "https://www.google.com",
    "color": 5
  },
  "message": "Note details has got successfully"
}

GET Search
 http://127.0.0.1:9090/notes/search

Request Headers

Authorization:Bearer TOKEN

Params

+ search_word(*required)
- limit(*optional)
- offset(*optional(starts from 0))

Response

{
  "status": true,
  "data": [
    {
      "noteId": "3",
      "email": "EMAIL",
      "title": "testing note",
      "subtitle": "1sss",
      "description": "postman Descreptionaaaaaaaaankjdkjkjk adel ayman any thing new word",
      "date": "Tuesday, 06 December 2022 14:37",
      "image": "https://avatars.githubusercontent.com/u/85571327?s=400&u=b39f4f0b0d503f5826f4d74fa6f951aee05703b6&v=4",
      "webLink": "https://github.com/adelayman1/QuranAppCoroutine",
      "color": 5
    }
  ],
  "message": "Notes have got successfully"
}

PATCH EditNote
 http://127.0.0.1:9090/notes/{note_id}

Request Headers

Authorization:Bearer TOKEN

Body raw (json)

{
  "title": "hello3!!!",
  "description": "Welcome to us again again!",
  "subtitle": "anything",
  "color": 2656,
  "webLink": "https://github.com/adelayman1",
  "image": null
}

Response

{
    "status": true,
    "data": {
        "noteId": "4",
        "email": "adelayman0000@gmail.com",
        "title": "aaa",
        "subtitle": "anything",
        "description": "Welcome to us again!",
        "date": "Wednesday, 07 December 2022 20:38",
        "image": "https://www.w3schools.com/css/paris.jpg",
        "webLink": null,
        "color": 2656
    },
    "message": "Note details has updated successfully"
}

Built With 🛠

Project Structure

📦API
 ┣ 📂data
 ┃ ┣ 📂models
 ┃ ┃ ┣ 📜Notes.kt
 ┃ ┃ ┗ 📜Users.kt
 ┃ ┣ 📂repositories
 ┃ ┃ ┣ 📜NoteRepositoryImpl.kt
 ┃ ┃ ┗ 📜UserRepositoryImpl.kt
 ┃ ┣ 📂source
 ┃ ┃ ┣ 📂dao
 ┃ ┃ ┃ ┣ 📂noteDao
 ┃ ┃ ┃ ┃ ┣ 📜NoteDAO.kt
 ┃ ┃ ┃ ┃ ┗ 📜NoteDAOImpl.kt
 ┃ ┃ ┃ ┗ 📂userDao
 ┃ ┃ ┃ ┃ ┣ 📜UserDAO.kt
 ┃ ┃ ┃ ┃ ┗ 📜UserDAOImpl.kt
 ┃ ┃ ┗ 📜DatabaseFactory.kt
 ┃ ┗ 📂utilities
 ┃ ┃ ┗ 📜UserJWTConfig.kt
 ┣ 📂di
 ┃ ┗ 📂modules
 ┃ ┃ ┗ 📜MainModule.kt
 ┣ 📂domain
 ┃ ┣ 📂models
 ┃ ┃ ┣ 📜BaseResponse.kt
 ┃ ┃ ┣ 📜NoteModel.kt
 ┃ ┃ ┗ 📜UserModel.kt
 ┃ ┣ 📂repositories
 ┃ ┃ ┣ 📜NoteRepository.kt
 ┃ ┃ ┗ 📜UserRepository.kt
 ┃ ┗ 📂usecases
 ┃ ┃ ┣ 📜AddNoteUseCase.kt
 ┃ ┃ ┣ 📜DeleteNoteUseCase.kt
 ┃ ┃ ┣ 📜GetAllUserNotesUseCase.kt
 ┃ ┃ ┣ 📜GetNoteDetailsUseCase.kt
 ┃ ┃ ┣ 📜LoginUseCase.kt
 ┃ ┃ ┣ 📜RegisterUseCase.kt
 ┃ ┃ ┣ 📜SearchNoteUseCase.kt
 ┃ ┃ ┗ 📜UpdateNoteDetailsUseCase.kt
 ┣ 📂plugins
 ┃ ┣ 📜Monitoring.kt
 ┃ ┣ 📜Routing.kt
 ┃ ┣ 📜Security.kt
 ┃ ┗ 📜Serialization.kt
 ┣ 📂routes
 ┃ ┣ 📂note
 ┃ ┃ ┣ 📂requestsModels
 ┃ ┃ ┃ ┣ 📜AddNoteParams.kt
 ┃ ┃ ┃ ┗ 📜UpdateNoteParams.kt
 ┃ ┃ ┗ 📜noteRoute.kt
 ┃ ┗ 📂user
 ┃ ┃ ┣ 📜CreateUserParams.kt
 ┃ ┃ ┣ 📜UserLoginParams.kt
 ┃ ┃ ┗ 📜userRoute.kt
 ┗ 📜Application.kt

LICENSE


Copyright (c) 2022 adelayman1

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.```