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.
- Dart SDK
- Firebase account and API credentials
- MongoDB Atlas account and cluster connection information
- GET /
Check if the server is running
Create a new user account
Body
{
"name": "write name here ",
"email": "write email here",
"password": "write password here"
}
Sign in to an existing user account
Body
{
"email": "write email here",
"password": "write password here"
}
Check if the user's token is valid and not expired
The authorization header must contain a Token as bearer
<b> authorization : bearer eyJhbGc........... </b>
Reset the password for a user account
Body
{
"email": "write email here",
}
Create a new post
Body
{
"title":"write title here",
"content":"write content here"
}
Retrieve all posts
Retrieve all posts by the current user
Retrieve a specific post by id
Retrieve a specific post by id that belongs to the current user
{
"title":"write title here",
"content":"write content here"
}
Update a specific post by id that belongs to the current user
Delete a specific post by id that belongs to the current user
The project is connected to the following services:
- Firebase: For user authentication.
- MongoDB Atlas: For storing and retrieving data.
Create a file called firebase.json in the root of the project, and add your Firebase API key and other relevant information.
To run the API, use the following command:
- Clone the repository:
git clone https://github.com/fahad0100/Example-of-building-a-Restful-API-in-the-Dart-.git
- Change into the project directory:
cd Example-of-building-a-Restful-API-in-the-Dart-
- Install the dependencies:
dart pub get
- Run the server:
dart bin/server.dart
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:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes.
- Commit and push your changes to your branch.
- Open a pull request.
You can also contact me at [email protected] for further discussions.
AliBaba cloud => http://8.213.24.202:8080
The API is hosted on GitHub
It has also been deployed on Heroku at Api