blgfstr-challenge
How to run
- Clone this repo
$ git clone git@github.com:MartinPavlik/blgfstr-challenge.git
- Install dependecies by running following command inside both
./frontend
and./backend
directories.
$ yarn install
- Start client and server by running:
$ yarn start
About
Backend
Backend is realized in ExpressJS framework.
In-memory storage is used instead of "real" database, so all data is lost when the server is restarted. The source code of this storage can be found here.
The idea
When user creates a link he obtains two different hashes - hash
and managementHash
(both of them are randomly generated).
hash
- part of the "public" URL that redirects to original urlmanagementHash
- this hash should be "secret" and only the user who created a link should know this hash, because it is used to manage the link (change the url or delete the link)
Usage of these two hashes is listed in this table:
Method | URL | Description |
---|---|---|
GET
|
/:hash
|
Redirects user to url associated with given :hash .
|
POST
|
/link
|
Creates link and returns JSON object containing Link info:
{
url,
hash,
managementHash
}
|
GET
|
/link/:managementHash
|
Returns JSON object containing Link info:
{
url,
hash,
managementHash
}
|
PUT
|
/link/:managementHash
|
Updates link and returns JSON object containing Link info:
{
url,
hash,
managementHash
}
|
DELETE
|
/link/:managementHash
|
Deletes link and returns JSON object containing info message: { message } .
|
Frontend
Frontend is a React web application created via create-react-app
generator.
Testing
You can execute tests by running this command
$ yarn test
in ./frontend
or ./backend
directory.
Test coverage
Backend
Only simple API test is currently available.
Frontend
- UI components - tested by smoke test
- Sagas - tested completely
- Reducers & Action Creators - only the more complicated ones are tested