Skip to content

LearningPlaygrounds/note-matic-backend

Repository files navigation

NoteMatic Logo

NoteMatic is an application that can be used to record important notes that can be accessed anytime and anywhere.

Description

NoteMatic is a RESTful API application designed to facilitate the recording of important notes that can be accessed anytime and anywhere. Developed with technologies such as Node.js, NestJS, and Prisma ORM. NoteMatic offers an efficient, secure, and reliable note-taking solution. With this NoteMatic application, users can create, read, update, delete and search notes through an intuitive and easy-to-use API interface.

  • Version : v1.0.0
  • Developer : Rumah Kodingku
  • Released On : June 16, 2024
  • Status : Stable Release
  • Contact : rumahkodingku45@gmail.com

Contents

  1. Description
  2. System Requirements
  3. Tech Stack
  4. Security
  5. Installation
  6. Setup Environment Variable
  7. Project Structure
  8. Running the App
  9. API Endpoints
  10. Usage Examples
  11. Authorization
  12. API Documentation

System Requirements

  • Node.js v14 or later
  • MySQL 5.7 or later
  • npm (Node Package Manager)

Tech Stack

  • NestJS
  • Prisma ORM
  • MySQL
  • TypeScript

Security

  • Authentication
  • Encryption and Hasing
  • Authorization
  • Cors
  • Rate Limiting
  • Helmet

Installation

# Navigate to project repository
$ cd NoteMatic

# Install all dependencies
$ npm install

Setup Environment Variable

# Change name file
$ cp .env.example .env

# Environment
PORT=YOUR PORT APP
DATABASE_URL=YOUR URL PRISMA MYSQL
JWT_SECRET=YOUR JWT SECRET

Project Structure

NoteMatic/
|-- dist/                           # Distribution file
|-- node_modules/                   # Node.js modules
|-- prisma/                         # Prisma
|   |-- migrations/
|   |-- schema.prisma
|-- src/
|   |-- common/                     # Common database, decorator, error, guard, middleware, strategy, validation
|   |   |-- database/
|   |   |-- decorator/
|   |   |-- error/
|   |   |-- guard/
|   |   |-- middleware/
|   |   |-- strategy/
|   |   |-- validation/
|   |   |-- common.module.ts        # Module common
|   |-- model/                      # Model features
|   |   |-- auth.model.ts
|   |   |-- notes.model.ts
|   |   |-- users.model.ts
|   |   |-- web.model.ts
|   |-- modules/                    # Main application modules
|   |   |-- auth/                   # Authentication module
|   |   |   |-- auth.controller.ts
|   |   |   |-- auth.module.ts
|   |   |   |-- auth.service.ts
|   |   |   |-- auth.validation.ts
|   |   |-- notes/                  # Notes module
|   |   |   |-- notes.controller.ts
|   |   |   |-- notes.module.ts
|   |   |   |-- notes.service.ts
|   |   |   |-- notes.validation.ts
|   |   |-- users/                  # Users module
|   |   |   |-- users.controller.ts
|   |   |   |-- users.module.ts
|   |   |   |-- users.service.ts
|   |   |   |-- users.validation.ts
|   |-- app.module.ts               # Root module for the application
|   |-- main.ts                     # Entry point for the application
|-- .env                            # Environment variables
|-- .eslintrc.js                    # Eslint file
|-- .gitignore                      # Git ignore file
|-- .prettier                       # Prettier formater file
|-- nest-cli.json                   # NestJS configuration
|-- package-lock.json               # Exact version dependencies
|-- package.json                    # Node.js project metadata
|-- README.md                       # Project README file
|-- tsconfig.build.json             # TypeScript build configuration
|-- tsconfig.json                   # TypeScript configuration

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

API Endpoints

Auth API

Summary Endpoint Method Authorization
Register /api/auth/register POST -
Login /api/auth/login POST -
Logout /api/auth/logout DELETE Bearer Token

Users API

Summary Endpoint Method Authorization
Get Data User /api/users GET Bearer Token
Update Password /api/users/update-password PUT Bearer Token

Notes API

Summary Endpoint Method Authorization Params Query
Create Note /api/note POST Bearer Token - -
Get Note By userId /api/note/all GET Bearer Token - -
Get Note By Id /api/note/:{noteId} GET Bearer Token noteId -
Update Note /api/note/:{noteId} PATCH Bearer Token noteId -
Delete Note /api/note/:{noteId} DELETE Bearer Token noteId -
Search Note /api/note GET Bearer Token - title

Usage Example

# Register
curl -X POST http://{your_url}/api/auth/register -H "Content-Type: application/json" -d '{"username":"test","password":"password"}'

# Get Note By Id
curl -X GET http://{your_url}/api/note/1 -H "Authorization: Bearer {token}"

Authorization

Use the following steps to get an authorization token:

  • Register or log in using the /api/auth/register or /api/auth/login endpoints.
  • Use the token received in the response to authorize further requests.

API Documentation

  • http://{your_url}/documentation

About

A Note App RESTful API built with Nest JS for learning purposes, featuring CRUD operations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •