Linet Mutheu
This is a REST API for querying and retrieving scoped news, users/employees and departments information. There is news available to all users without navigating into any department, and news classified within departments..
You need to have the following installed on your machine
- Java JDK
- Gradle
- JDK
- Maven
- Java IDE (Intellij)
- Postman
- Postgres
To access this project on your local files, you can clone it using these steps
- Open your terminal
- Use this command to clone `$ git clone https://github.com/MutheuLinet/Organisational-News-API.git
- This will clone the repository into your local folder
- Navigate to the folder you cloned into, within src/main/java/App.java and open it with intellij.
- Run App on localhost:4567
- Via postman, use localhost url to navigate different routes accordingly either using post and get to test the api.
URL(http://localhost:4567{URL Below}) | HTTP VERB | DESCRIPTION |
---|---|---|
/department/new | POST | Add a new department |
/departments | GET | Get all departments |
/departments/:id | GET | Get specific department by its id |
/users/new | POST | Add a user |
/users | GET | Get all users |
/users/:id | GET | Get a user by their id |
/departments/:id/users | GET | Get all users in a specific department |
/news/new | POST | Add news |
/ | GET | Get all news |
/news/:id | GET | Get news by id |
/department/:departmentId/news/new | POST | Post department news by department id |
/department/:departmentId/news | GET | Get department news by department id |
- Creating Department
{ "name":"HR", "description":"Editing of books", "size": 10 }
- Creating User
{ "name":"Stacy", "position":"Assistant HR", "role":"Recruit employees" }
- Creating News
{ "title":"How to Motivate Employees", "content":"Revise employee hierarchy of needs" }
You may also want to contribute to enhance a functionality:
- Fork the repository to your GitHub account
- Create a new branch (git switch -c ft-development)
- Make the changes you intend
- Add changes to reflect the changes made
- Commit your changes (git commit -m 'additional info')
- Push to the branch (git push origin ft-develop)
- Create a Pull Request.
The user is able to;
- Run the App on your terminal
- Add Department, User or News object.
- View Department, User or News object details. (It also allows a user to Test the output before actual running of the App)
- Navigate to the folder you cloned into, within src/test/java/models and open it with intellij. Select the DepartmentTests, UserTests or NewsTest
- Right click within the open test file and run the tests on your terminal.
- Launch postgres
- Type in psql Run these commands
- CREATE DATABASE organisational_news; \c organisational_news
- CREATE TABLE IF NOT EXISTS departments (id serial PRIMARY KEY, name varchar, description varchar, size varchar);
- CREATE TABLE IF NOT EXISTS users(id serial PRIMARY KEY, name varchar, position varchar, role varchar, department_id int);
- CREATE TABLE IF NOT EXISTS news(id serial PRIMARY KEY, title varchar, content varchar, department_id int);
- Java
- Gradle
- Spark
- Junit
This project is under the MIT licence
Copyright (c) 2022 Linet Mutheu