Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.
/ OrgNewsPortal Public archive

REST API for storing and querying scoped news and information within an organization

License

Notifications You must be signed in to change notification settings

benruwel/OrgNewsPortal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Organisational News Portal

REST API for querying and retrieving scoped news and information within an organization

Ben Ruwel

Table of Contents

About The Project

This is a REST API that is used to post news, view information of departments and its employees(users). It has features that allows one access specific info about users and departments, view a list of all the users in a department and also the list of departments a user is associated with.

Built With

This is program is wholely written in Java and built with

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

In order to build this app locally, first make sure you have all the programs listed in Built with. Some can be added as dependencies, please check with the build tool you wish to use.o

Installation

  1. Clone the repo

    $ git clone https://github.com/benruwel/OrgNewsPortal.git
  2. If you don't have Postgres installed on your local PC visit this to install it

  3. Enable gradle to import all the dependencies automatically

Usage

This api is hosted on Heroku, so you can choose to consume using this link https://org-news-portal.herokuapp.com/

These are the REST api routes:

Behavior Path Http Verb
Create a new departmetnt /department/new POST
Delete a specific department /department/:department_id DELETE
View info a specific department /department/:departmetn_id GET
Get a list of all departments /departments GET
Create a new user/employee /users/new POST
Get a list of users /users GET
Post news about a specific department /departments/:department_id/news/new POST
Get a list of the news relating to specific department /departments/:department_id/news GET
Add a user to a department departments/:department_id/user/:user_id/new POST
View a list of the employees/users in a department /departments/:department_id/users GET
View list of departments an employee is associated with /user/:user_id/departments GET

You may also choose to build this project locally and consume the api with the localhost port with the following steps:

  1. Open your preferred terminal

  2. You will need to create the databases with a specific schema, navigate to src/main/resources/DB and run this command

    $ psql > create.sql
    

    This creates org_news_portal (developmetn db) and org_news_portal_test (test db) on your local machine

    If in any instance you will require to delete the databases, run this:

    $ psql > drop.sql
  3. Then to run the project, navigate to your project's root directory run the project with

    $ gradle run
  4. Open postman and use the localhost:4567 URL to test the endpoints stipulated above.

BDD

This project uses Gson to change Java objects to JSON format, which is the golden standard for most apis.

POST method behavior:

  • User fires a POST method e.g. POST department/new, though the data may differ according to the given body object, there will be a similar 201 response with the generated Json object.
    {
        "name": "HR",
        "id": 2,
        "description": "Comfortable workspaces to thrive in",
        "number_of_employees": 2
    }

GET method behavior

  • User fires a GET method e.g. GET /departments, in this case, the response will be a Json object with an array of all the departments.
    [
        {
            "name": "Software Dev",
            "id": 1,
            "description": "Hot Java all day, both coffee and code",
            "number_of_employees": 10
        },
        {
            "name": "HR",
            "id": 2,
            "description": "Comfortable workspaces to thrive in",
            "number_of_employees": 2
        }
    ]

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

My email - [email protected]

Acknowledgements

About

REST API for storing and querying scoped news and information within an organization

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages