axolotl / Backend

Node, express and SQLite backend for Droom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Droom API

Proposal

HEROKU DEPLOYMENT

https://droom-backend.herokuapp.com/


START SERVER

  • run yarn server

Axios Example

NAVIGATION

Authentication

Register | Login

Users

Get All Users | Get User Info | Get User by Id | Update User

Companies

Get All Companies | Get Company Info | Get Company by Id | Update Company

Jobs

Get All Jobs | Create Job | Get Job by Id | Update Job Delete Job

ENDPOINTS

Authentication

  1. Register

    Method URL: /auth/register

    HTTP method: [POST]

    Headers

    name type required description
    Content-type String Yes Must be application/json

    Body for User

    name type required description
    email String Yes must be unique
    password String Yes required
    type String Yes must be either 'user' or 'company'

    example

        {
            email: "johnDoe@test.com",
            password: "password123"
            type:'user'
        }
    

    Body for Company

    name type required description
    companyName string Yes
    email String Yes must be unique
    password String Yes required
    type string Yes must be either 'user' or 'company'

    example

        {
            email: "johnDoe@test.com",
            password: "password123"
            type:'company'
        }
    

  1. Login

    Method URL: /auth/login

    HTTP method: [POST]

    Headers

    name type required description
    Content-type String Yes Must be application/json

    Body

    name type required description
    email String Yes required
    password String Yes required

    example

        {
            email: "test@test.com",
            password: "password123"
        }
    

    On success return user object

         {
             "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoyMSwiaWF0IjoxNTUyMTczNDgzLCJleHAiOjE1NTI2MDU0ODN9.AIYdpeMoNtT3FHrSc1_Srrj3dLQfHl1gRNK3hicOe2M",
             "userInfo": {
                 "id": 21,
                 "firstName": "mike",
                 "lastName": "landers",
                 "email": "test@test.com",
                 "occupation": null,
                 "experience": null,
                 "interests": null
             }
         }
    

    On success return company object

         {
             "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxLCJpYXQiOjE1NTIyNDU4ODgsImV4cCI6MTU1MjY3Nzg4OH0.JCY10oa6KVN5HttwK27PCLWr_m8SU9Ptz2lXoryuPeo",
             "companyInfo": {
                 "id": 1,
                 "name": "apple",
                 "email": "test3@test.com",
                 "bio": null,
                 "address": null
             }
         }
    

Users

  1. Get All Users

    Method URL: /users

    HTTP method: [POST]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return array


       [
           {
               "id": 1,
               "firstName": "Orlando",
               "lastName": "Nitzsche",
               "occupation": "Regional Functionality Strategist",
               "experience": "experience",
               "interests": "interests"
           },
           {
               "id": 2,
               "firstName": "Delphine",
               "lastName": "Shanahan",
               "occupation": "Product Factors Orchestrator",
               "experience": "experience",
               "interests": "interests"
           }
       ]


  1. Get user info

    Method URL: /users/info

    HTTP method: [GET]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return object

 "id": 1,
    "firstName": "Laurence",
    "lastName": "Bechtelar",
    "occupation": "Central Mobility Director",
    "experience": "experience",
    "interests": "interests",
    "saved": [
        {
            "job_id": 47,
            "jobTitle": "Internal Quality Agent",
            "jobPosition": "Architect",
            "jobDescription": "Regional",
            "jobRequirements": "Brand",
            "jobSalary": 903,
            "jobTags": "dolore eos quia",
            "jobOpenDate": "1552373894247.0",
            "jobCloseDate": "1559589532036.0"
        },
        {
            "job_id": 49,
            "jobTitle": "Future Interactions Technician",
            "jobPosition": "Analyst",
            "jobDescription": "District",
            "jobRequirements": "Data",
            "jobSalary": 18,
            "jobTags": "animi quia omnis",
            "jobOpenDate": "1552355593356.0",
            "jobCloseDate": "1570538807737.0"
        }
    ]

  1. Get user by ID

    Method URL: /users/:id

    HTTP method: [GET]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return object

    {
        "id": 2,
        "firstName": "Imani",
        "lastName": "Heidenreich",
        "occupation": "Future Tactics Agent",
        "experience": "experience",
        "interests": "interests"
    }


  1. Update User

    Method URL: /users/update

    HTTP method: [PUT]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token must be from a user account

    Body

    name type required description
    firstName string No
    lastName string No
    occupation string No
    experience string No
    interests string No
       {
           firstName: "John,
           lastName: "Doe"
       }
    

    Response

    On success return 1


Companies

  1. Get All Companies

    Method URL: /companies

    HTTP method: [GET]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return array


    [
        {
            "id": 1,
            "companyName": "Company",
            "email": "user@company.com",
            "bio": null,
            "address": null
        },
        {
            "id": 2,
            "companyName": "Apple",
            "email": "hr@apple.com",
            "bio": null,
            "address": "1 Infinite Loop"
        }
    ]

  1. Get Company Info

    Method URL: /companies/info

    HTTP method: [GET]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return object

    {
        "id": 2,
        "companyName": "Apple",
        "email": "hr@apple.com",
        "bio": null,
        "address": "1 Infinite Loop"
    }

  1. Get Company by Id

    Method URL: /companies/:id

    HTTP method: [GET]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return object

    {
        "id": 2,
        "companyName": "Apple",
        "email": "hr@apple.com",
        "bio": null,
        "address": "1 Infinite Loop",
        "companyJobs": [
            {
                "id": 3,
                "jobTitle": "title",
                "jobPosition": "Position",
                "jobDescription": "Description",
                "jobRequirements": "Requirements",
                "jobSalary": 100000,
                "jobTags": ["tech", "janitor"],
                "jobOpenDate": "March 11th, 2019",
                "jobCloseDate": "June 1st, 2019",
                "company_id": 2
            }
        ]
    }

  1. Update Company

    Method URL: /companies/update

    HTTP method: [PUT]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token must be from a company account

    Body

    name type required description
    companyName string No
    email string No
    bio string No
    address string No
    Can send any part of the body that needs updating:
    
    companyName, email, bio, address
    
       {
           bio: "This is a new bio",
           address: "123 Company St, Company Town, USA"
       }
    

    Response

    On success return 1


Jobs

  1. Get All Jobs

    Method URL: /jobs

    HTTP method: [GET]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return array


    [
        {
            "id": 1,
            "jobTitle": "Dynamic Program Administrator",
            "jobPosition": "Consultant",
            "jobDescription": "Direct",
            "jobRequirements": "Web",
            "jobSalary": 553,
            "jobTags": "tempora",
            "jobOpenDate": "1552312445647.0",
            "jobCloseDate": "1579476170156.0",
            "company_id": 11
        },
        {
            "id": 2,
            "jobTitle": "International Configuration Developer",
            "jobPosition": "Supervisor",
            "jobDescription": "Future",
            "jobRequirements": "Marketing",
            "jobSalary": 206,
            "jobTags": "nostrum",
            "jobOpenDate": "1552303764015.0",
            "jobCloseDate": "1579102031521.0",
            "company_id": 4
        }
    ]

  1. Create Job

    Method URL: /jobs

    HTTP method: [Post]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Body

    name type required description
    jobTitle String No
    jobPosition String No
    jobDescription String No
    jobRequirements String No
    jobSalary Integer No
    jobTags String No
    jobOpenDate Integer No
    jobCloseDate Intteger No

    Response

    On success return 1


  1. Get Job by Id

    Method URL: /jobs/:id

    HTTP method: [GET]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token

    Response

    On success return object

    {
    "id": 13,
    "jobTitle": "Customer Research Apprentice",
    "jobPosition": "Executive",
    "jobDescription": "Lead",
    "jobRequirements": "Accounts",
    "jobSalary": 704,
    "jobTags": "voluptas",
    "jobOpenDate": "1552282766773.0",
    "jobCloseDate": "1579250581673.0",
    "company_id": 1
}

  1. Update Job

    Method URL: /jobs/update/:id

    HTTP method: [PUT]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token must be from a company account

    Body

    name type required description
    jobTitle String No
    jobPosition String No
    jobDescription String No
    jobRequirements String No
    jobSalary Integer No
    jobTags String No
    jobOpenDate Integer No
    jobCloseDate Intteger No
       {
           jobSalary: 50000,
       }
    

    Response

    On success return 1


  1. Delete Job

    Method URL: /jobs/:id/delete

    HTTP method: [DELETE]

    Headers

    name type required description
    Content-type String Yes Must be application/json
    Authorization String Yes Token must be from a company account

    Response

    On success return status(204)


Axios Examples

  1. Axios Post Request

        axios({
            method: "post",
            url: `https://${API_URL}/endpoint`,
            headers: {
                Authorization: token
            },
            data: {
                email: "johndoe@email.com",
                password: "password123"
            }
            })
            .then((res) => console.log(res))
            .catch(err => console.log("error", err))
    

About

Node, express and SQLite backend for Droom


Languages

Language:JavaScript 100.0%