REST API using Dart

This API provides endpoints for authentication and managing user posts. It is built using the Dart programming language and connects to Firebase for authentication and MongoDB Atlas for storing data.

Prerequisites

  • Dart SDK
  • Firebase account and API credentials
  • MongoDB Atlas account and cluster connection information

Postman workspace URL:

Postman

Endpoints

Health Check

  • GET / Check if the server is running

Authentication

  • POST /api_v1/auth/signup Create a new user account
  • POST /api_v1/auth/signin Sign in to an existing user account
  • GET /api_v1/auth/checkauth Check if the user’s token is valid and not expired
  • POST /api_v1/auth/resetpassword Reset the password for a user account

User

  • POST /api_v1/user/newpost Create a new post
  • GET /api_v1/user/allposts Retrieve all posts
  • GET /api_v1/user/myposts Retrieve all posts by the current user
  • GET /api_v1/user/post/ Retrieve a specific post by id
  • GET /api_v1/user/mypost/ Retrieve a specific post by id that belongs to the current user
  • PUT /api_v1/user/updatepost/ Update a specific post by id that belongs to the current user
  • DELETE /api_v1/user/deletepost/ Delete a specific post by id that belongs to the current user

Services

The project is connected to the following services:

  • Firebase: For user authentication.
  • MongoDB Atlas: For storing and retrieving data.

Set up

Set up your Firebase credentials

Create a file called firebase.json in the root of the project, and add your Firebase API key and other relevant information.

Running the API

To run the API, use the following command:

  1. Clone the repository:
git clone https://github.com/fahad0100/Example-of-building-a-Restful-API-in-the-Dart-.git
  1. Change into the project directory:
cd Example-of-building-a-Restful-API-in-the-Dart-
  1. Install the dependencies:
dart pub get
  1. Run the server:
dart bin/server.dart

Contributing

We welcome contributions to this project. If you have an idea for an improvement or a bug to report, please open an issue. If you would like to make a change yourself, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Make your changes.
  4. Commit and push your changes to your branch.
  5. Open a pull request.

You can also contact me at [email protected] for further discussions.

Deployment

The API is hosted on GitHub It has also been deployed on Heroku at Api

GitHub

View Github