Git Product home page Git Product logo

stuneckt-submission's Introduction

Stuneckt Internship Assignment Submission (Microblogging API)

This is a simple RESTful API for a microblogging platform like Twitter or LinkedIn. It allows users to create posts, follow other users, and retrieve posts made by themselves or other users.

Setup

Prerequisites

  • Node.js installed on your machine.
  • TypeScript installed globally on your machine
  • MongoDB installed locally or a remote MongoDB instance.

Installation

  1. Clone the repository:

    git clone https://github.com/singhchanmeet/stuneckt-submission
  2. Navigate to the server directory:

    cd server
  3. Install dependencies:

    npm install
  4. Set up environment variables:

    Create a .env file in the root directory and define the following variables:

    PORT=3000
    MONGODB_URI=mongodb://localhost:27017/microblogging
    JWT_SECRET=your_secret_key
    

    Adjust the MONGODB_URI and JWT_SECRET values as per your setup.

  5. Compile the Typescript to Javascript:

    npm run build
  6. Start the server:

    npm run start

API Endpoints

Auth

  • POST /auth/signup
    • Create a new user account.
    • Request Body:
      {
        "username": "example_user",
        "email": "[email protected]",
        "password": "your_password",
        "name": "User Name"
      }
  • POST /auth/login
    • Log in an existing user.
    • Request Body:
      {
        "username": "example_user",
        "password": "your_password"
      }

Users

  • GET /user/profile

    • Retrieve the profile of the authenticated user.
  • POST /user/follow/:usernameToFollow

    • Follow a user by their username.
  • PUT /user/update

    • Update the details of the authenticated user.
    • Request Body:
      {
        "username": "new_username",
        "email": "[email protected]",
        "name": "New Name"
      }

Posts

  • POST /posts/create
    • Create a new post.
    • Request Body:
      {
        "content": "This is a sample post content."
      }
  • GET /posts/all
    • Retrieve all posts.
  • GET /posts/user/:userId
    • Retrieve posts by a specific user.
    • Replace :userId with the user's ID.

Error Handling

The API handles errors gracefully and returns appropriate HTTP status codes along with error messages in JSON format.

stuneckt-submission's People

Contributors

singhchanmeet 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.