Giter Site home page Giter Site logo

jinnjarburger / snap-snippet Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 75.28 MB

A code sharing platform built using spring boot, hibernate and JPA as ORM with PostgreSQL which also follows a RESTful architecture.

License: Apache License 2.0

Java 37.42% JavaScript 3.84% CSS 22.03% HTML 36.71%

snap-snippet's Introduction

Snap-Snippet


Springboot-version Java-version Gradle-version


A code sharing platform built using spring boot, hibernate and JPA as ORM with PostgreSQL which also follows a RESTful architecture.

Tech


Springboot Thymeleaf Gradle Hibernate PostgreSQL Heroku


Application Features

  • Post Snippet and get a unique id
  • Post Snippet with added restrictions
    • Time restriction
    • Views restriction
    • or Both
  • View top 10 latest unrestricted codes
  • Api features
    • Post
    • View
    • Delete

Build with gradle

Before starting make sure gradle is downloaded. To get started with gradle click here.

For manual installation

After downloading the latest gradle distribution configure your PATH environment variable to include the bin directory of the unzipped distribution.

For Linux & MacOS:
$ export PATH=$PATH:/opt/gradle/gradle-7.2/bin
For Windows:

In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.

Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-7.2\bin (make sure to unzip the content of the downloaded folder to C:\Gradle). Click OK to save.

To verify the installation open a console (or a Windows command prompt) and run gradle -v to run gradle and display the version, e.g.:

> gradle -v

------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------

Building the project

As gradle is already initialized, after downloading the project all that's left to do is build the project. To build the project run the gradle build command following the gradle clean command.

> gradle clean
Starting a Gradle Daemon (subsequent builds will be faster)

BUILD SUCCESSFUL in 12s
1 actionable task: 1 executed
> gradle build

> Task :test
2021-08-19 13:56:06.991  INFO 12964 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-08-19 13:56:06.991  INFO 12964 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2021-08-19 13:56:09.695  INFO 12964 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

BUILD SUCCESSFUL in 1m 7s
7 actionable tasks: 7 executed

Run application locally

To run the app locally the following changes need to be made to the application.properties file:

# Set the database name as desired
spring.datasource.url=jdbc:postgresql://localhost:5432/snippet
spring.datasource.username=postgres
# Set the password as you desire
spring.datasource.password=Adnanrocks247

Now to set up the database in PostgreSQL we first open the psql shell (to install PostgreSQL, follow this link). After opening the shell press Enter four times and when asked for the password, type in the password used whilst installing PostgreSQL (refer to the previous link).

  1. Login to PostgreSQL
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (13.4)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.
postgres=#
  1. Enter the command

CREATE DATABASE snippet;

  1. To make sure the desired database is created enter the \l command to view all the available databases
postgres=# \l
                                                 List of databases
   Name    |  Owner   | Encoding |          Collate           |           Ctype            |   Access privileges
-----------+----------+----------+----------------------------+----------------------------+-----------------------
 postgres  | postgres | UTF8     | English_United States.1252 | English_United States.1252 |
 snippet   | postgres | UTF8     | English_United States.1252 | English_United States.1252 |
 template0 | postgres | UTF8     | English_United States.1252 | English_United States.1252 | =c/postgres          +
           |          |          |                            |                            | postgres=CTc/postgres
 template1 | postgres | UTF8     | English_United States.1252 | English_United States.1252 | =c/postgres          +
           |          |          |                            |                            | postgres=CTc/postgres
(4 rows)
  1. Now rebuild the project or simply use an IDE (preferably Intellij) to run the application and then to view the web app use this link http://localhost:8080/.

Using the Api features

Postman

  • Post a snippet

To post a snippet open Postman then open a Post tab and paste the following link with the following end points https://snap-snippet.herokuapp.com/api/code/new.

Next in the body parameter type in the code with restrictions in the following JSON format:

{
  "code": "Secret code",
  "time": 5000,
  "views": 5
}

If the code is to be posted with no restrictions simply assign 0 to "time" and "views":

{
  "code": "Secret code",
  "time": 0,
  "views": 0
}

The reply should be in a json format with a unique id:

{
  "id": "983fca68-303c-4a52-b55e-87ac3c3b5fb2"
}
  • Get a snippet

To get a snippet open Postman then open a Get tab and paste the following link with the following end points (with the desired unique id) https://snap-snippet.herokuapp.com/api/code/983fca68-303c-4a52-b55e-87ac3c3b5fb2.

The response would be in the following json format:

{
  "code": "Secret code",
  "date": "2021/08/19 09:54:52",
  "time": 3800,
  "views": 4
}
  • Delete a snippet

To delete a snippet open Postman then open a DEL tab and paste the following link with the following end points ( with the desired unique id) https://snap-snippet.herokuapp.com/api/code/delete/983fca68-303c-4a52-b55e-87ac3c3b5fb2.

The response will be a simple Deleted! string message.



License

License

snap-snippet's People

Contributors

jinnjarburger avatar

Stargazers

Mustafa Galib avatar Yasin KILINÇ avatar Tabassum Alam avatar Shahriyar Hossain avatar Muhammad Anwarul Azim avatar  avatar Mohammed Niaz Ul Haque avatar

Watchers

 avatar

Forkers

digits88

snap-snippet's Issues

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.