-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement ping endpoint and documentation
- use typebox to verify inputs ardatan/feTS#902 (comment)
- Loading branch information
Showing
6 changed files
with
97 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
"description": "GraphQL API server for clients like rumors-site and rumors-line-bot", | ||
"main": "index.js", | ||
"repository": { | ||
"url": "[email protected]:MrOrz/rumors-api.git", | ||
"url": "[email protected]:cofacts/rumors-api.git", | ||
"type": "git" | ||
}, | ||
"author": "MrOrz <[email protected]>", | ||
"author": "Cofacts WG <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "pm2-dev start --timestamp process-dev.json", | ||
|
@@ -31,6 +31,7 @@ | |
"@google-cloud/vision": "^3.1.4", | ||
"@grpc/grpc-js": "^1.6.7", | ||
"@grpc/proto-loader": "^0.5.0", | ||
"@sinclair/typebox": "^0.33.22", | ||
"apollo-server-koa": "^2.11.0", | ||
"cli-progress": "^3.9.1", | ||
"dataloader": "^2.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Cofacts Admin API | ||
|
||
Welcome! You have been granted access to this API by the Cofacts Work Group. | ||
|
||
To access the API programmatically, you need to use [Service Tokens](https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/#connect-your-service-to-access). | ||
Please contact Cofacts Work Group to get your `CLIENT_ID` and `CLIENT_SECRET`. | ||
|
||
Here are some examples with `curl` command (`<current host>` denotes the host name of this document page, i.e. URL without "/docs".): | ||
```sh | ||
# Get OpenAPI schema via curl command | ||
curl -H "CF-Access-Client-Id: <CLIENT_ID>" -H "CF-Access-Client-Secret: <CLIENT_SECRET>" <current host>/openapi.json | ||
|
||
# Call POST /ping and get pong + echo | ||
curl -XPOST -H "CF-Access-Client-Id: <CLIENT_ID>" -H "CF-Access-Client-Secret: <CLIENT_SECRET>" -d '{"echo": "foo"}' <current host>/ping | ||
``` | ||
|
||
The response would attach a cookie named `CF_Authorization` that you may use for [subsequent requests](https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/#subsequent-requests). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** Input and output types are manually aligned to the actual API */ | ||
export default function pingHandler({ echo }: { echo: string }): string { | ||
return `pong ${echo}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters