Git Product home page Git Product logo

journal-backend's Introduction

Journal-Backend

This project is used to provide CRUD APIs to the Journal application in the frontend. It has been deployed in render through this link. You can also choose to install the project as follows:

Setting up and running the backend

1. Prerequisites

  • Ensure Node.js is installed in your machine.

2. Installation

  • Clone the repository:

git clone https://github.com/naim-2/Journal-Backend
cd Journal-Backend
  • Install the dependencies:

npm install

3. Running the Server

  • Run the following commands to start the server:

npx tsc
npx ts-node-dev src/index.ts

API Documentation

1. Registering a new user

  • Endpoint: /api/auth/register
  • Method: POST
  • Request body: { "username": "string", "email": "string", "password": "string" }
  • Response: User registered
  • Screenshot: image

2. Logging in as a registered user

  • Endpoint: /api/auth/login
  • Method: POST
  • Request body: { "email": "string", "password": "string" }
  • Response: { "token": "string" }
  • Screenshot: image

3. Updating username and/or password

  • Endpoint: /api/user
  • Method: PUT
  • Header: { "Authorization": "Bearer <your_jwt_token>" }
  • Request body (at least username or password must be included as not null): { "email": "string", "username": "string", "password": "string" }
  • Response: User updated successfully
  • Screenshot: image

4. Adding new journal

  • Endpoint: /api/journal

  • Method: POST

  • Header: { "Authorization": "Bearer <your_jwt_token>" }

  • Request body: { "title": "string", "content": "string", "category": "string", "date": "string (YYYY-MM-DD)" }

  • Response: { "id": "number", "title": "string", "content": "string", "category": "string", "date": "string (YYYY-MM-DD)" }

  • Screenshot: image

5. Getting all journals

  • Endpoint: /api/journal
  • Method: GET
  • Header: { "Authorization": "Bearer <your_jwt_token>" }
  • Response: [{ "id": "number", "title": "string", "content": "string", "category": "string", "date": "string (YYYY-MM-DD)" }, { "id": "number", "title": "string", "content": "string", "category": "string", "date": "string (YYYY-MM-DD)" }]
  • Screenshot: image

6. Editing existing journal

  • Endpoint: /api/journal
  • Method: PUT
  • Header: { "Authorization": "Bearer <your_jwt_token>" }
  • Request body: { "id": "number", "title": "string", "content": "string", "category": "string", "date": "string (YYYY-MM-DD)" }
  • Response: { "id": "number", "title": "string", "content": "string", "category": "string", "date": "string (YYYY-MM-DD)" }
  • Screenshot: image

7. Deleting a journal

  • Endpoint: /api/journal
  • Method: DELETE
  • Header: { "Authorization": "Bearer <your_jwt_token>" }
  • Request body: { "id": "number" }
  • Response: { "id": "number" }
  • Screenshot: image

journal-backend's People

Contributors

naim-2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.