GithubHelp home page GithubHelp logo

tejaskh3 / sample-profile-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from real-dev-squad/sample-profile-service

0.0 0.0 0.0 4.31 MB

It is a sample profile service. Profile service is what users have to make in RealDevSquad and link it to the identity service(project in RealDevSquad), by doing this their profile data is synced from their profile service to our database whenever they update it.

JavaScript 100.00%

sample-profile-service's Introduction

User-Profile-Service-RDS

Introduction

Follow the instructions below to deploy and link your profile service.

Profile Service Feature

  • User Profile Service consists of 3 APIs /health, /profile, and /verification
  • This is a template for creating your own NodeJs backend code of profile service.
  • /health checks whether the server is up and running
  • /profile returns data of the user to whom profile Service belongs. It is a protected API so that no one can take your information.
  • /verification API returns a hash based on the special chaincode generated by the user at identity service.
  • This service is used by Real Dev Squad to connect and help new people come aboard to learn development.

Tutorial

What are you building?

Profile Service is your service which will be deployed and verified by you with the help of some pre-created APIs and contains all the relevant data about you, used for building your profile and getting yourself an identity in Real Dev Squad. This service will be maintained by you throughout the term of your journey in Real Dev Squad.

Pre-requisites (Should be installed)

Steps to Follow

Step 1

Fork the Template Repository from the top right corner

image

Step 2

Create a new fork, ensure that Owner is selected as your GitHub username, and the repository name can be named as :

<YOUR_NAME>'s-profile-service

Example: Rohan's-profile-service

image

Step 3

Now when you have forked the repository. We will clone the repository on our PC.

Click on the Code button on the right just above the code

gitclone

Ensure that HTTPS is selected and copy the link

Now enter the following command in the terminal to clone the repository:

git clone <link you have copied>

Step 4

Open the cloned repository in VScode or your code editor

Step 5

Open New Terminal in VSCode and run the following command yarn or yarn install This will bring in all the packages and dependencies if any left.

Making It Your Own

Now we will create a file local to you that contains all your profile data. We will use environment variables so that only you and the authorized RDS service can access your data and not anyone who has your deployment link

Step 1:

Add a file in your main folder and name it as .env

Step 2:

Copy the following data in your .env file and replace right side values with your real information

FIRST_NAME='first_name'
LAST_NAME='last_name'
EMAIL='email_id'
PHONE='your contact number without country code'
YOE=your years of experience
COMPANY='Your company / University you are in'
DESIGNATION='Current Role'
GITHUB_ID='github_id<github_id not the full url>'
LINKEDIN_ID='linkedin_id<linkedin_id not the full url>'
TWITTER_ID='twitter_id<twitter_id not the full url>'
INSTAGRAM_ID='instagram_id<instagram_id not the full url>'
WEBSITE='your portfolio website. Leave empty if not there'
CHAIN_CODE='Your chain code. Will be generated in further steps when deploying'

Note: FIRST_NAME, LAST_NAME, EMAIL, PHONE, COMPANY, DESIGNATION, GITHUB_ID, LINKEDIN_ID, and CHAIN_CODE are required fields. If you don't have these fields or you have these with empty values or spaces, they will fail in validation and your profile service get blocked. PHONE should be only digits, YOE is a number and can be a minimum of 0.

Step 3:

Add a gitignore file and add a .env file in it so it is not tracked and your personal information is never uploaded to Github.

Let's Test It

Now we will test if our profile service is working on our local device before deploying

Step 1

Open Insomnia and select debug in the top center of the screen

image

You will see the above screen

Step 2

Now go to VSCode open your profile service and type the following code in the new terminal: yarn run dev This command will run your service locally

Step 3

Open Insomnia and enter the following link with GET Request http://localhost:8000/health

image

image

Congratulations you have run your first service and tested your first API ๐ŸŽ‰๐ŸŽ‰

Step 4

To test other APIs we need to deploy our service and generate chaincode from the RDS identity service which is used to verify your profile service

Deployment

Now we will deploy our service so that it is running on a server accessible to everyone and is not running only locally on your machine.

Step 1

Login to your Render account. After logging in go to your dashboard and you will see this interface.

image

Step 2

Click on New and you will see a dropdown having multiple options.

image

Click on Web Service

Step 3

Now, you will be directed to a new page where you have to configure your GitHub or GitLab account so that you can deploy your profile service on Render.

image

Now select your profile service repository to deploy.

Then click on Connect.

Step 4

Now you will be seeing your deploy section of the Render app as below.

image

Now, fill in all the inputs correctly.

Then, select the Free tier as shown below,

image

Step 5

Now click on the advanced option below the plans section.

Step 6

You will find the Add Environment Variables option along with other options. Leave others as default and click on the add environment variables button.

Add Environment Variables

Note: Make sure you add all the keys, website can be optional.

Step 7

Make sure you clear the cache and redeploy your service after storing env specifically chain_code.

Step 8

Now you will find a box for Key and one box for Value. Copy the first key from your .env file into the KEY box and copy its value(Without apostrophes) in the VALUE box and click on Add button. For empty values add a space in the VALUE box.

keyval

Step 9

Do Step 7 Repeatedly for all values of the .env file but leave chaincode because that will be generated later on.

Step 10

And you are done with deployment. Now only the deployment link is protected and you have your info which cannot even be uploaded by mistake on GitHub.

Step 11

Finally, scroll down and you will find a button named Create Web Service. Click on that button to deploy your code.

Create Web Service

๐Ÿฅณ Congratulations, you have successfully deployed your profile service.

Linking Profile Service

Now you will be linking your deployed service with us i.e. RDS.

Step 1

Go to Real Dev Squad website and click on the Sign In With GitHub button in the navbar as shown below.

image

Link your GitHub account, and complete the SignUp steps. Note: Only for users who don't have an account on the Real Dev Squad website or who haven't linked their GitHub account on the Real Dev Squad website.

Step 2

Go to My Site or you can simply click the user greeting as shown below (this is after you have Signed In with your GitHub account)

a

Once you land on my site, you will have to go to the Identity Tab (P.S. You can directly click on this hyperlink to get you to the desired page).

Step 3

You get to see something like the below form

b

Click on Get Started

c

Click on Generate Chaincode to generate the chaincode.

d

Then Click on Copy to copy the chaincode. Note: Keep this generated code very safe as you will be able to see it once only.

Step 4

Update the chaincode in deployment from Dashboard -> click on your deployed service -> Environment -> update the chaincode as discussed in Step 7 of Deployment.

Now we have completed all the information.

Step 5

Now that you have pushed your code with the chaincode. Enter your deployed service URL here.

e

Click on Next. Then, click on Link.

f

Woohoo now wait for a few seconds or minutes to get your service verified by the Real Dev Squad service.

g

Once you are verified you will get to see a verification message that your verification is completed.

h

Awesome, Congratulations ๐Ÿฅณ ๐ŸŽ‰ on becoming a user in Real Dev Squad and

Welcome to Real Dev Squad ๐Ÿฅณ ๐ŸŽ‰

**Note: ** If you are unable to verify your service or there are some errors that you encountered. Please reach out to members of Real Dev Squad from here

Additional Information

  1. You can run the yarn run test cmd local after completing all information and see if any test is failing. If any of the tests is failing please re-check the information entered by you in the .env file. These tests check the functionality of all three APIs.

sample-profile-service's People

Contributors

rahulgoyal-tech avatar lakshayman avatar manish591 avatar shreya-mishra 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.