<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Totoola Kenny</title>
    <description>The latest articles on DEV Community by Totoola Kenny (@totoolakehinde).</description>
    <link>https://dev.to/totoolakehinde</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F470000%2F7c63ebc5-3a16-4966-bf47-d4e1aa5de7ba.png</url>
      <title>DEV Community: Totoola Kenny</title>
      <link>https://dev.to/totoolakehinde</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/totoolakehinde"/>
    <language>en</language>
    <item>
      <title>Why All You Get Is Rejection?</title>
      <dc:creator>Totoola Kenny</dc:creator>
      <pubDate>Mon, 23 Nov 2020 08:56:16 +0000</pubDate>
      <link>https://dev.to/totoolakehinde/why-all-you-get-is-rejection-16np</link>
      <guid>https://dev.to/totoolakehinde/why-all-you-get-is-rejection-16np</guid>
      <description>&lt;p&gt;Hey awesome reader!&lt;/p&gt;

&lt;p&gt;Do you ever wonder why all you get or mostly get is a rejection? Aren't you good enough? Aren't you standing out well? Do you need to work more on your skills? And a lot more questions regarding why you keep getting a rejection!!&lt;/p&gt;

&lt;p&gt;Regardless of your career path, I believe you're really doing your best to secure the job, position, internship, contract, and so on! But do you really think something is wrong with your ending up with rejections?&lt;/p&gt;

&lt;p&gt;Having asked yourself these questions, I will be sharing with you ideas that can help you stand out and ways you keep to in successfully securing that role, position, or internship!&lt;/p&gt;

&lt;p&gt;Before I go on! Know that you just found yourself a piece of gold! What would you do with it? It's left to you! But I would advise you to take part in this discussion by sharing your thoughts and opinions in the comment sections!!&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Questions And Important Information About Applications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Do you ever think you stand out in every application review?&lt;/strong&gt;
Open applications to roles, scholarships, and other opportunities from various organizations receive thousands of applicants! Have you ever imagined if the recruiters read and review every single resume uploaded? Yes! You may feel you have said more than enough about yourself and your skills in your resume! At this point, do you think your resume got to the front desk of the recruiters?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why wouldn't your resume get to the front desk? In cases where there's no application fee levied on your applications(most application fees are meant to sum up for recruiters! By that is relieving to them they are getting pay in return), there are tools used to filter resumes uploaded by applicants! Do you think your resume made it through the filtering process?? Most recruiters filter the resumes to match certain keywords(stacks, skills that match what they are looking for).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What are you bringing to the table?&lt;/strong&gt; Do you ever consider the things you will like to contribute to the team or the organization if you're selected?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Approaches To Securing The Perfect Role/Position
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Making Connections&lt;/strong&gt;: Agree with me that your network can judge your net worth and your chances of getting opportunities! Do you know applicants send recruiters privates messages and build good relationships?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make networks with people already at your desired organizations! Do you know there are direct hires too? Which doesn't require you submitting application forms but might require directing technical tests and a faster mode of hiring!&lt;/p&gt;

&lt;p&gt;Your connections with internal people from these organizations will give you chances of learning about changes and immediate openings! &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Have a Solid Online Presence / Profile&lt;/strong&gt;: Your public profiles and your public activities should talk more about your recent and most updated skills! Talk more about what you're building, things you're doing, impacts you're making!! Believe me, there are lots of people seeing you!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's called the internet! Very wide and spacious for everyone to be seen and noticed! Sharing update about the things you do and your projects may get the attention of these organizations! The project you just talked about might be the next feature they are thinking of implementing!&lt;/p&gt;

&lt;p&gt;You wouldn't be surprised when these organizations start reaching out to you personally on how you can be useful to the team! Or how you can make an impact working with them!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Self Confidence&lt;/strong&gt;: Agree with me that you don't need to know about every single technology to get a role at these firms! You only need the confidence to make it work!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should always be ready to learn new things when you're considering a position! Forget about whatever it is you know! Whenever you are in the new tech space, it's always different approaches to the way they do things, the way they deploy their codes, their methods, and so on! You must be ready to learn new things!&lt;/p&gt;

&lt;p&gt;I would like to share my experience with you all on I worked on my first ever real-life project built with PHP and MySQL! I had no prior knowledge about PHP and it's usage! The project was built in weeks and used by thousands of people! You might be thinking if that was easy? It wasn't! But I was confident enough to take up the task and learn something new!&lt;/p&gt;

&lt;p&gt;Organizations are interested in smart people! You need to prove that you're really smart!&lt;/p&gt;

&lt;p&gt;Another thing you should always know is that there's no tech expert who claims to know about every technology! You should never be worried about technology! Try to ask people and make researches! There is documentation with the best approaches to be used for each tech!&lt;/p&gt;

&lt;p&gt;Equip yourself with the ability to make researches and find solutions! 70% of the problems you encounter have their solution published online somewhere! But you will only find them when you research your problems!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reaching Out To These Organizations Personally&lt;/strong&gt;: A have a conversation with a user on &lt;a href="https://jumpstart.me/r/kehinde-totoola" rel="noopener noreferrer"&gt;Jumpstart.me&lt;/a&gt; A recruiting platform where you have to make up your profile and keep it updated as you can and be able to apply to roles from organizations in just a click!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A user shared how she keeps reaching out to organizations daily! Reaching out to organizations she's interested in!&lt;/p&gt;

&lt;p&gt;The conversation went as:&lt;br&gt;
Me:&lt;em&gt;"Hey Christina,&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Read your comment about find companies and personal emails daily, send these people personal emails!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How has it been so far with you?"&lt;/em&gt;&lt;br&gt;
Christina:&lt;em&gt;"I am on day 5. So I take a good amount of research into what organizations I would want to work with. I am not just applying to jobs because it will be a job for me. I google top companies in tech, non-profits, or etc. Whatever your field of interest. Then I will spend time finding who might be in charge of recruiting and email them personally. If you have a hard time finding the emails you can find them on &lt;a href="https://hunter.io/" rel="noopener noreferrer"&gt;hunter.io&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;These are really helpful tools and people usually are really helpful. Email back and point you in the direction of someone who can use your skills. So far I am on day 5. That is 15 emails. I have received 4 emails back and some LinkedIn connections. I am having a hard time because I am a transitional career person and my degree doesn't really relate to my skill set. I am hopeful so I will just keep looking. Linkedin is a great place to look at jobs and companies but I wouldn't rely on applying via those automated systems. I hope that helps!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cheers,&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Christina Keys"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To understand the conversation better, Christina intends in sending or writing 3 emails directly to the organizations she's interested in daily! That sounds like a great approach! It really is!! This helps you make research about the organization ahead and learn about ways you can contribute to the organization! With that, you know the things to include in your emails.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;APPLY APPLY APPLY&lt;/strong&gt;: Nithinaray - An IOS developer at Twitter shared on a Podcast(#ShowupStandout): "You miss 100% of the opportunities you don't apply to"! There's no chance of getting an offer if you don't apply! Even if they accept only one person, that person could be you. So why not apply?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Listen to the podcast &lt;a href="https://podcasts.apple.com/us/podcast/showupstandout/id1494981707?i=1000497762574" rel="noopener noreferrer"&gt;here&lt;/a&gt;! Talking about how you can stand out at recruiting events and platforms to increase your chances of securing your desired roles.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1325822958565281793-145" src="https://platform.twitter.com/embed/Tweet.html?id=1325822958565281793"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1325822958565281793-145');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1325822958565281793&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resume Formatting&lt;/strong&gt;: The best format to submit your resumes is in PDF formats! Making sure your Resume is well structured from your contact info to your skills, to education, and the rest! Proper structuring of your resume makes it easy for automated tools and programs to read through and successfully filter the required information needed!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;This is an open discussion! Your thoughts and opinions are welcomed! What other approaches do you think will increase your chances of getting that position? How have you tackled rejections? &lt;/p&gt;

&lt;p&gt;It's never cool to feel rejected for roles you think you're a great fit! You're really doing your best! You're the best! You need high self-esteem and confidence in this labor market! Tell the world you're the right person for that role!&lt;/p&gt;

&lt;p&gt;Things you should know! These top developers have applied to hundreds of positions and get rejected too! A very minimal number will reach out to them for technical tests and maybe just 2 organizations will end up offering a position! Do not feel stressed when rejected! It's a chance to work more on yourself and try again! At that point, your price just increased!!&lt;/p&gt;

&lt;p&gt;Remember to like the post and comment! Let's learn together!&lt;br&gt;
Follow me on &lt;a href="https://twitter.com/KTotoola" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>help</category>
      <category>career</category>
    </item>
    <item>
      <title>Build A Laundry CRUD API with FastAPI using MongoDB - 1</title>
      <dc:creator>Totoola Kenny</dc:creator>
      <pubDate>Sun, 20 Sep 2020 12:15:50 +0000</pubDate>
      <link>https://dev.to/totoolakehinde/build-a-laundry-crud-api-with-fastapi-using-mongodb-1-3ccl</link>
      <guid>https://dev.to/totoolakehinde/build-a-laundry-crud-api-with-fastapi-using-mongodb-1-3ccl</guid>
      <description>&lt;p&gt;Building a Laundry CRUD API using FastAPI with the support of MongoDB as the database technology! I often use cloud storage like MongoDB in my projects to provide protection, the most reliable backups system, easy access to your data from anywhere, and most importantly is its low cost of access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table Of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Basic CRUD in a Laundry API&lt;/li&gt;
&lt;li&gt;Installing FastAPI&lt;/li&gt;
&lt;li&gt;Setting up MongoDB Atlas&lt;/li&gt;
&lt;li&gt;Building each API Endpoints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Grab your popcorn, sit comfortably and let's go&lt;/em&gt; 🚀&lt;/p&gt;

&lt;p&gt;But wait... Do you have a basic knowledge using MongoDB? Have you written programs in Python? If YES!! Then you're a good fit to continue here. What if No! Don't Panic I got you covered by simplifying every single step in this article.&lt;/p&gt;

&lt;h4&gt;
  
  
  MongoDB??
&lt;/h4&gt;

&lt;p&gt;Curious about what MongoDB is? or how it's being used?&lt;br&gt;
MongoDB is a document-oriented database program which requires no SQL, and stores data in JSON-like formats.&lt;/p&gt;
&lt;h4&gt;
  
  
  FastAPI??
&lt;/h4&gt;

&lt;p&gt;FastAPI is a modern, &lt;strong&gt;fast&lt;/strong&gt; framework for building APIs with Python. Note that I had to bold the word &lt;strong&gt;fast&lt;/strong&gt;! As the name implies "FastAPI", it is very fast and easy to code and automatically generates well swagger documentation for your API. That's sweet right! I know you will like this. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Get a drink and have a sip, Let's move&lt;/em&gt; 🚀&lt;/p&gt;
&lt;h3&gt;
  
  
  Basic CRUD in a Laundry API &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A laundry service API should require the following basic CRUD(Create Read Update Delete) functions in managing bookings of services(laundry pickups, Updating status of service, canceling pickups, and so on).&lt;/p&gt;

&lt;p&gt;Since this article is part one in building a laundry service API, we will focus on login/signup API endpoints(with no authentications yet).&lt;/p&gt;

&lt;p&gt;Endpoints to be built in this article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Login&lt;/li&gt;
&lt;li&gt;signup&lt;/li&gt;
&lt;li&gt;update-profile&lt;/li&gt;
&lt;li&gt;book-service&lt;/li&gt;
&lt;li&gt;update-pickup&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Installing FastAPI &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;After highlighting the endpoints we're working on in this article, let's install FastAPI! &lt;em&gt;You should have VSCode and your preferred browser ready(I use Chrome)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Firstly, open a folder(preferably on your desktop making it easy to locate), name it "laundryAPI".&lt;br&gt;
Open the folder with VSCode and create a file "main.py"&lt;/p&gt;

&lt;p&gt;Now open your VSCode Terminal and type this:&lt;br&gt;
&lt;em&gt;Note: You can create a virtual environment but not necessary&lt;/em&gt;&lt;br&gt;
&lt;code&gt;pip install fastapi&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will need an ASGI server for production such as &lt;em&gt;Uvicorn&lt;/em&gt;:&lt;br&gt;
&lt;code&gt;pip install uvicorn&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After successfully installing FastAPI, let's write our first API program for our root endpoint(homepage):&lt;br&gt;
In the main.py, type the following code;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from typing import Optional

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def index():
    return {"message": "Hello World"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's run and test our API:&lt;br&gt;
type this in the terminal to run the code;&lt;br&gt;
&lt;code&gt;uvicorn main:app --reload&lt;/code&gt;&lt;br&gt;
Our API should be running on &lt;a href="http://127.0.0.1:8000" rel="noopener noreferrer"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We successfully built our API 🎉🎉&lt;/p&gt;
&lt;h3&gt;
  
  
  Setting up MongoDB Atlas &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;We successfully wrote our first FastAPI program! You see how fast and easy it is? Very fast!! I know you like that! Now, let's set up our MongoDB Atlas to store our laundry service data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Signup for a free MongoDB cloud storage &lt;a href="https://www.mongodb.com/cloud/atlas/signup" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;After signup, create a project,  name it 'laundrystore'&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FHp91d1g%2FScreenshot-179.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FHp91d1g%2FScreenshot-179.png" alt="You should see this now"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click build a cluster to create an Atlas:&lt;em&gt;free atlas&lt;/em&gt;!
&lt;em&gt;New clusters take 1-3 minutes to provision&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;After the cluster has been created, click on 'connect' for details on how to connect your cloud storage to your app!&lt;/li&gt;
&lt;li&gt;Set your cloud storage access permissions to allow connection from anywhere!&lt;/li&gt;
&lt;li&gt;Set a database username and password, and choose a connection method!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FLJk6vpS%2FScreenshot-180.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FLJk6vpS%2FScreenshot-180.png" alt="Choose a connection Method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For this API, choose "Connect your application" and copy the connection string provided after selecting Python as the driver to use it!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Keep your connection string, we will use it in our API development! Do not forget your database username and password&lt;/em&gt;&lt;br&gt;
&lt;em&gt;We have successfully created and setup our MongoDB Atlas! We now have cloud storage for our Laundry API&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Building each API Endpoints &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let's work on the endpoints highlighted for this part one article:&lt;br&gt;
starting with the signup endpoint!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In this article, we will be using schematics to organize and validate our data model types and structures.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Install schematics:&lt;br&gt;
&lt;code&gt;pip install schematics&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;create a &lt;code&gt;settings.py&lt;/code&gt; file and type the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# MongoDB attributes
mongodb_uri = 'mongodb+srv://kenny:123CloudLaundry@cluster0.5xmt6.mongodb.net/&amp;lt;usersdata&amp;gt;?retryWrites=true&amp;amp;w=majority'
port = 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note that I replaced some strings in the connection string we copied from MongoDB with the database username and password we created&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;create a &lt;code&gt;connection.py&lt;/code&gt; file and type the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pymongo import MongoClient
import settings

client = MongoClient(settings.mongodb_uri, settings.port)
db = client['usersdata']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This is basically a connection file that creates a connection with MongoClient! Also, a database called 'usersdata'&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, update your &lt;code&gt;main.py&lt;/code&gt; file with the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from typing import Optional

from fastapi import FastAPI
import connection
from bson import ObjectId
from schematics.models import Model
from schematics.types import StringType, EmailType


class User(Model):
    user_id = ObjectId()
    email = EmailType(required=True)
    name = StringType(required=True)
    password = StringType(required=True)

# An instance of class User
newuser = User()

# funtion to create and assign values to the instanse of class User created
def create_user(email, username, password):
    newuser.user_id = ObjectId()
    newuser.email = email
    newuser.name = username
    newuser.password = password
    return dict(newuser)

app = FastAPI()


# Our root endpoint
@app.get("/")
def index():
    return {"message": "Hello World"}

# Signup endpoint with the POST method
@app.post("/signup/{email}/{username}/{password}")
def signup(email, username: str, password: str):
    user_exists = False
    data = create_user(email, username, password)

    # Covert data to dict so it can be easily inserted to MongoDB
    dict(data)

    # Checks if an email exists from the collection of users
    if connection.db.users.find(
        {'email': data['email']}
        ).count() &amp;gt; 0:
        user_exists = True
        print("USer Exists")
        return {"message":"User Exists"}
    # If the email doesn't exist, create the user
    elif user_exists == False:
        connection.db.users.insert_one(data)
        return {"message":"User Created","email": data['email'], "name": data['name'], "pass": data['password']}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;-I will explain what we did there, but that is simply an implementation of the signup endpoint without hashing our password values!&lt;/em&gt;&lt;br&gt;
&lt;em&gt;-We will also learn how to hash our passwords before storing them into the cloud!&lt;/em&gt;&lt;br&gt;
&lt;em&gt;-The Signup endpoint simply creates a new user into the MongoDB storage and returns information about the user-created or either returns a piece of information that the user exists!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Type &lt;code&gt;uvicorn main:app --reload&lt;/code&gt; to run the code!&lt;/p&gt;

&lt;p&gt;Now visit &lt;a href="http://127.0.0.1:8000/docs" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/docs&lt;/a&gt; from your browser to use the FastAPI swagger UI to test our API.&lt;/p&gt;

&lt;p&gt;This part one article is basically for us to learn for CRUD works and how it's being implemented! In the next article, we will learn how to professionally structure our code and folders! Professionally structuring our code simply means how to reuse codes! Qualities of a good program are the ability to reuse codes, class, functions, and so on.&lt;/p&gt;

&lt;p&gt;Implementing the login endpoint: for the sake of python beginners, we're not using packages for our logins and signups!&lt;/p&gt;

&lt;p&gt;Update your &lt;code&gt;main.py&lt;/code&gt; file with the following code(updated with the login endpoint)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from typing import Optional

from fastapi import FastAPI
import connection
from bson import ObjectId
from json import dumps
from schematics.models import Model
from schematics.types import StringType, EmailType


class User(Model):
    user_id = ObjectId()
    email = EmailType(required=True)
    name = StringType(required=True)
    password = StringType(required=True)

# An instance of class User
newuser = User()

# funtion to create and assign values to the instanse of class User created
def create_user(email, username, password):
    newuser.user_id = ObjectId()
    newuser.email = email
    newuser.name = username
    newuser.password = password
    return dict(newuser)

# A method to check if the email parameter exists from the users database before validation of details
def email_exists(email):
    user_exist = True

    # counts the number of times the email exists, if it equals 0 it means the email doesn't exist in the database
    if connection.db.users.find(
        {'email': email}
    ).count() == 0:
        user_exist = False
        return user_exist

# Reads user details from database and ready for validation
def check_login_creds(email, password):
    if not email_exists(email):
        activeuser = connection.db.users.find(
            {'email': email}
        )
        for actuser in activeuser:
            actuser = dict(actuser)
            # Converted the user ObjectId to str! so this can be stored into a session(how login works)
            actuser['_id'] = str(actuser['_id'])    
            return actuser


app = FastAPI()


# Our root endpoint
@app.get("/")
def index():
    return {"message": "Hello World"}


# Signup endpoint with the POST method
@app.post("/signup/{email}/{username}/{password}")
def signup(email, username: str, password: str):
    user_exists = False
    data = create_user(email, username, password)

    # Covert data to dict so it can be easily inserted to MongoDB
    dict(data)

    # Checks if an email exists from the collection of users
    if connection.db.users.find(
        {'email': data['email']}
        ).count() &amp;gt; 0:
        user_exists = True
        print("USer Exists")
        return {"message":"User Exists"}
    # If the email doesn't exist, create the user
    elif user_exists == False:
        connection.db.users.insert_one(data)
        return {"message":"User Created","email": data['email'], "name": data['name'], "pass": data['password']}

# Login endpoint
@app.get("/login/{email}/{password}")
def login(email, password):
    def log_user_in(creds):
        if creds['email'] == email and creds['password'] == password:
            return {"message": creds['name'] + ' successfully logged in'}
        else:
            return {"message":"Invalid credentials!!"}
    # Read email from database to validate if user exists and checks if password matches
    logger = check_login_creds(email, password)
    if bool(logger) != True:
        if logger == None:
            logger = "Invalid Email"
            return {"message":logger}
    else:
        status = log_user_in(logger)
        return {"Info":status}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;-This code is instructing enough with the comments!&lt;/em&gt;&lt;br&gt;
&lt;em&gt;-The login endpoint uses the &lt;code&gt;check_login_creds(), email_exists(), log_user_in()&lt;/code&gt; methods to: check if the user exists, then validates the users details and logs the user in if values matches&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FwY29yWt%2FScreenshot-181.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FwY29yWt%2FScreenshot-181.png" alt="Tests Login Endpoint"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The above image shows the result returned from the API when credentials for login isn't correct!&lt;/em&gt;&lt;br&gt;
&lt;em&gt;In the next article, we will also learn how to handle errors so our API doesn't break! for example when the connection to MongoDB is timed out, the API returns a 500 response code(application error)! It's more professional and advisable to use error handlings in codes so the application doesn't break!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;In this article, we tried to make it as simplified as possible for every individual to understand!&lt;br&gt;
No authentications, sessions, or any complicated method in building an API!&lt;br&gt;
You can get the code &lt;a href="https://github.com/Totoola-Kehinde/laundryAPI" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Star the repo and follow me to!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy learning&lt;/em&gt;🎉🎉🎉&lt;/p&gt;

</description>
      <category>python</category>
      <category>mongodb</category>
    </item>
  </channel>
</rss>
