bobocode-labs / gojohnny-rest-api Goto Github PK
View Code? Open in Web Editor NEWREST API for GoJohnny project
REST API for GoJohnny project
Provide an working example using their API
POST ../places/{place_id}/photo
that receives photo as request bodyphotoUrl
of the place using given placeId
.Current naming convention for SQL migration scripts is potentially dangerous. Flyway checks the latest version in the flyway_schema_version
and applies all migrations with larger versions. It means that if two developers started working on tickets #14 and #18 at the same time, and ticket #18 was released before the other one, then migration of ticket #14 will be ignored which is incorrect.
Starting from now use the following simple naming convention: Vx.y__Description
, every time you submit new migration, you should use the latest value of x
, and y
will be used for major db changes.
Suppose current database version is 1.8
, and you need to create a migration to add new column photoUrl
to Place
. Your migration name should be V1.9__Add_photo_url_to_place
.
1.0
Create and configure new profile testing
that will be used to run Spring tests.
For this profile:
Create SpringBoot integration test that will call a REST API endpoints and verify results.
Test at least the following scenarios:
Use Spring testing
profile.
Heroku provides three variables to config database connection:
SPRING_DATASOURCE_URL
SPRING_DATASOURCE_USERNAME
SPRING_DATASOURCE_PASSWORD
See heroku docs
In order to be able to connect local database also we have to provide some additional configuration.
TODO:
prod
to be used for herokudev
and configure it to use local postgresAdd new field type
to class Place
.
PlaceType
with values PEAK
, CAMP
, SOURCE
, and UNKNOWN
- defaultid
fields for REST endpointsREST API should provide a GET
endpoint by url ../places/search/name
that receives one string parameter called query
and returns a list of places found by query. Query represents a piece of name.
Use Rest Repository to implement that endpoint. E.g. your PlaceRepository
should have one more custom method that is implemented using @Query
and JPQL.
Create Spring Boot integration test the will check CRUD operations for Photo
entity. Use testing
profile.
Currently we use Hikari connection pool for all profiles. In order to save resources we can disable it for local development.
Configure application.yml
to disable Hikari for profile dev
Investigate OSM API and create a working example.
We are going to build our own database of places and other spatial data. Most of the content that we are going to store will be produces by users of our system, hence will be unique. However, information like place name, altitude or location is not unique. It means that we should found some open API that allows to get required geographical data. The larges open resource is Open Street Map (OSM). Mapbox is also using OSM.
At some point, we are going to use OSM API and copy some data into our own database. Therefore, we need to know the API, and the format of the data.
Focus on places only. You should be able to answer questions like how to load places by name, by type or by location.
Create endpoint GET ../places/osm
, that takes five parameters:
mitLat
maxLat
minLng
maxLng
type
- optionalit should use provided parameters, load data from OSM and return the response.
Initialize field Place#type
with UKNOWN
value
In class Place
create new String
field named photoUrl
. This field should be optional. All database schema changes should done using migration scripts.
String description
field to class Place
.Configure proper encoding so we can store and retrieve Ukrainian words.
Cover this case with a proper integration test. E.g. store new place with a Ukrainian name, and then retrieve it from the database using REST API.
Create new entity PhotoComment
that will represent comments added to Photo
. Add the following mandatory fields:
id
- auto generatedtext
creationTime
photo
- a reference to a Photo
author
- reference to User
, which added a commentCreate corresponding JPA repository and the migration script.
Create new GET
endpoint using url .../places/bounds
. It should receive four mandatory parameters:
minLat
minLng
maxLat
maxLng
The response should be a list of places following GeoJSON standard.
Create a Spring Boot integration test that will verify CRUD endpoints for User
entity.
You should use testing
profile for that.
Place
entity contain wrong mapping on place type
.
It is @Column(nullable = false, columnDefinition = "UNKNOWN")
but should be
@Column(nullable = false, columnDefinition = "VARCHAR (255) DEFAULT UNKNOWN")
JPA entity Place
has different constraint that database table.
See class Place
and migration script V5_2_2018.10.06__Create_table_place.sql
.
Update entity and create new migration script to fix database table. Place requirements that should be updated:
location
is mandatoryaltitude
is NOT mandatoryInvestigate possible ways to run Spring Boot app locally (having active profile dev
) without changing the application.yml
.
Check Spring docs Set the Active Spring Profiles, and add corresponding hints to the README file.
In order to build an online map for our platform, we're gonna use map provider Mapbox. Mapbox provides an open source Java Script library Mapbox GL JS. We need to integrate it into our react based front-end.
Check out docs, and find existing solutions. Pick one or more solution that is suitable for us. Create a demo page as an example.
See the article Mapbox GL JS + React
In order to make it simple for now use default Hibernate sequence name.
See Hibernate docs Using sequences
Create new User
entity with the following fields mandatory fields:
id
- autogenerated using db sequencefirstName
lastName
email
password
creationTime
Add corresponding JPA repository and migration script.
Since we are going to implement integration with OSM, it's better to have store OSM id for each place.
osm_id
Create a registration form that allows to create a new user account. From should consists of four required fields:
Check out how to use OSM API. See ticket #31.
Create new endpoint POST ../places/osm
that takes five parameters:
mitLat
maxLat
minLng
maxLng
type
- optionalImplement corresponding service logic. It should call OSM API and using the following parameters load places. All new places should be stored in our database according to our own format.
Create new Photo
entity with the following mandatory fields:
id
- auto generatedurl
- a valid URL where photo is locatedcreationTime
author
- a reference to User
that posted a photoAdd corresponding JPA repository and the migration script.
Update README.MD file, and add description of how to name flyway migration scripts
Configure the application to be successfully deployed on heroku.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.