A microservice written in TypeScript for monitoring saved urls.
Clone the repository
git clone [email protected]:ondra-m/apilift.git
Install dependencies
npm install
You can configure the app by JSON file or by environment variables.
- Check and modify config.json at the root and run. If you won't change any attributes, the server will starts at
localhost:3000
npm run start config.json
- Via environment variables
APILIFT_DB_HOST=localhost \
APILIFT_DB_USER=root \
APILIFT_DB_PASSWORD=root \
APILIFT_DB_NAME=apilift \
APILIFT_WEB_PORT=3000 \
npm run start
- Using docker
Make sure that docker-compose is installed.
docker-compose up
By default 3 users are created (see src/migrate/seed.ts for more informations)
- Admin accessToken="d70bce60-73ed-11ea-bc9d-b7f14190b585"
- Applifting accessToken="93f39e2f-80de-4033-99ee-249d92736a25"
- Batman accessToken="dcb20f8a-5657-4f1b-9f7f-ce65739b359e"
You must include accessToken
to Authorization header (see at examples below)
Returned data are always within user's context.
Show info about current users
curl --request GET \
--url http://localhost:3000/whoami \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585'
List of all endpoints
curl --request GET \
--url http://localhost:3000/endpoints \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585'
Get a single endpoint
:id
an id of the existing endpoint (otherwise 404 is returned)
curl --request GET \
--url http://localhost:3000/endpoints/:id \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585'
Create new endpoint
interval
url will be checked in this interval (in seconds)name
name of the endpointurl
url of the endpoint (must include protocol)
curl --request POST \
--url http://localhost:3000/endpoints \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585' \
--header 'Content-type: application/json' \
--data '{
"interval": 10,
"name": "Check applifting.cz",
"url": "https://www.applifting.cz"
}'
Update saved endpoint
:id
an id of the existing endpoint- see previous example for parameters description
curl --request PATCH \
--url http://localhost:3000/endpoints/:id \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585' \
--header 'Content-type: application/json' \
--data '{
"interval": 50,
"name": "Test",
"url": "http://example.net"
}'
Delete an endpoint
:id
an id of the existing endpoint
curl --request DELETE \
--url http://localhost:3000/endpoints/:id \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585'
List of all results
endpointId
results for specific endpoint (optional)
curl --request GET \
--url http://localhost:3000/monitoring_results?endpointId=2 \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585'
Get a single result
This route (compared to the previous) return payload and information about endpoint.
:id
an id of the existing result (otherwise 404 is returned)
curl --request GET \
--url http://localhost:3000/monitoring_results/:id \
--header 'Authorization: Bearer d70bce60-73ed-11ea-bc9d-b7f14190b585'
First, configure config.test.json
for your test environemnt and
npm run test
Or if you want test everything if you change any file run
npm run test:dev
- A lot of
.catch
is missing - Using some existing ORM would be better