Hi all, I'm sorry to say but starting October 7, 2024 the plant server will no longer be available at plantserver.fun. Going to let the domain expire since I think this server's time has come I don't want to keep paying for the domain. Sorry for any inconvenience! You're welcome to take this and spin it up yourself if you'd like!
Love,
βJason, Sept 2024
A simple Express server for week 7 review
$ npm install
.env
based on .env_sample
and set the port number and API key.$ node index.js
# Or run with change watcher:
$ npm run dev
You must provide an API key as a query string to every request.
?api_key=<YOUR API KEY>
{
"id": 1,
"name": "Pam",
"type": "Big Green One",
"water_frequency": 7,
"image_url": "https://images.pexels.com/photos/3644742/pexels-photo-3644742.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
"last_watered": 1620925225646
}
{
"name": "Name",
"type": "Type",
"water_frequency": 5, // Number of days
"image_url": "Url",
"last_watered": "YYYY-MM-DD" // Optional
}
{
"name": "Michael",
"water_frequency": 5
}
All GraphQL queries should be sent as GET or POST requests to /graphql
Plant {
id ID
name! String
type! String
water_frequency! Int
image_url! String
last_watered! Float
}
plant
Returns one plant by ID.
Name | Type | Description | Required? | |
---|---|---|---|---|
Arguments | id |
ID |
The ID of the plant to get | β |
Possible Returns | plant.* |
Plant |
Any requested field from the Plant object | --- |
plants
Returns a list of plants
Name | Type | Description | Required? | |
---|---|---|---|---|
Arguments | none | --- | --- | --- |
Possible Returns | --- | Plant[] |
A list of Plant objects and any of their requested fields | --- |
addPlant
Creates a new plant
Name | Type | Description | Required? | |
---|---|---|---|---|
Arguments | name |
String |
The name of the new plant | β |
type |
String |
The type of the new plant | β | |
water_frequency |
Int |
Number of days after which the plant should be watered | β | |
image_url |
String |
The URL for the image of the plant | β | |
last_watered |
String |
When the plant was last watered in "YYYY-MM-DD" format | β | |
Possible Returns | plant.* |
Plant |
Any requested field from the newly created Plant object | --- |
editPlant
Edits a plant given its ID.
Name | Type | Description | Required? | |
---|---|---|---|---|
Arguments | id |
ID |
The ID of the plant to edit | β |
name |
String |
The new name for the plan | β | |
type |
String |
The new type for the plant | β | |
water_frequency |
Int |
Number of days after which the plant should be watered | β | |
image_url |
String |
The new URL for the plant's image | β | |
last_watered |
String |
When the plant was last watered in "YYYY-MM-DD" format | β | |
Possible Returns | plant.* |
Plant |
Any fields from the updated Plant object | --- |
deletePlant
Deletes a plant given its ID.
Name | Type | Description | Required? | |
---|---|---|---|---|
Arguments | id |
ID |
The ID of the plant to delete | β |
Possible Returns | plant.id |
ID |
The ID of the deleted plant | --- |
waterPlant
Waters a plant given its ID.
Name | Type | Description | Required? | |
---|---|---|---|---|
Arguments | id |
ID |
The ID of the plant to water | β |
Possible Returns | plant.* |
Plant |
Any requested field from the updated Plant object | --- |