-By Collins Netia Odinga
A REST API for querying and retrieving scoped news and information.
- Basic Git knowledge, including an installed version of Git.
- Your application must run on the OpenJDK version 11 or higher
- navigate to
src/main/resources/sql
to find database - Type psql
- CREATE DATABASE news_ping; \c news_ping ;
- \dt to view the tables;-
- \q to quit
\c news_ping ;
CREATE TABLE users(
id serial PRIMARY KEY,
name VARCHAR,
rank VARCHAR,
staffRole VARCHAR,
dept_id INTEGER
);
CREATE TABLE departments(
id serial PRIMARY KEY,
name VARCHAR,
description VARCHAR
);
CREATE TABLE news(
id serial PRIMARY KEY,
title VARCHAR,
content VARCHAR,
userid INTEGER,
departmentid INTEGER
);
- Java v11
- Gradle
- Spark Framework
- CSS (Bootstrap)
- JUnit v4.12
- Jacoco Plugin
- postgresql
-
To run the application, in your terminal:
- Clone or download the Repository
- cd into directory then run
cd news-portal
- Rebuild the Project Using Intellij IDEA or ...
- Open terminal command line then navigate to the root folder of the application.
- Run
gradle run
command. - Navigate to
http://localhost:4567/
in your browser.
Want to contribute? Great!
To fix a bug or enhance an existing module, follow these steps:
- Fork the repo
- Create a new branch (
git checkout -b improve-feature
) - Make the appropriate changes in the files
- Add changes to reflect the changes made
- Commit your changes (
git commit -am 'Improve feature'
) - Push to the branch (
git push origin improve-feature
) - Create a Pull Request on GitHub
GET /departments
curl -i -H 'Accept: application/json' http://localhost:0.0.0.0:4567//departments
{
"status": 200,
"message": "Success",
"data": [
[]
]
}
POST /departments/new
curl -i -H 'Accept: application/json' -d 'name=Foo&status=new' http://localhost:4567/departments/new
{
"status": 201,
"message": "Department Added Successfully!",
"data": {}
}
`GET /departments/news
curl -i -H 'Accept: application/json' http://localhost:0.0.0.0:4567/departments/news
{
"status": 200,
"message": "Success",
"data": [
[]
]
}
post //departments/news/new
curl -i -H 'Accept: application/json' http://localhost:4567/departments/news/new
{
"status": 201,
"message": "News Added to department Successfully!",
"data": {}
}
POST //users/new
curl -i -H 'Accept: application/json' -d 'name=Bar&junk=rubbish' http://localhost:4567/users/new
{
"status": 404,
"message": "Invalid Request",
"data": {}
}
get/users/new
curl -i -H 'Accept: application/json' -d 'name=Bar&junk=rubbish' http://localhost:4567/users
{
"status": 404,
"message": "Invalid Request",
"data": {}
}
`de //users
curl -i -H 'Accept: application/json' -d 'name=Bar&junk=rubbish' http://localhost:4567/users/new
{
"status": 404,
"message": "Invalid Request",
"data": {}
}
MIT Copyright (c) 2022 Collins Netia Odinga
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.