Skip to content

Commit 613ef94

Browse files
committed
Upgrade docs endpoint
1 parent 1dc2a1f commit 613ef94

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

backend/api/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Backend API
22

3-
This is the code for the API running at `api.compassmeet.com`.
3+
This is the code for the API running at https://api.compassmeet.com.
44
It runs in a docker inside a Google Cloud virtual machine.
55

66
### Requirements
77

88
You must have the `gcloud` CLI.
99

10-
On MacOS:
10+
On macOS:
1111

1212
```bash
1313
brew install --cask google-cloud-sdk
@@ -60,7 +60,7 @@ Set up the saved search notifications job:
6060

6161
```bash
6262
gcloud scheduler jobs create http daily-saved-search-notifications \
63-
--schedule="0 19 * * *" \
63+
--schedule="0 16 * * *" \
6464
--uri="https://api.compassmeet.com/internal/send-search-notifications" \
6565
--http-method=POST \
6666
--headers="x-api-key=<API_KEY>" \
@@ -155,3 +155,8 @@ docker exec -it $(sudo docker ps -alq) sh
155155
docker run -it --rm $(docker images -q | head -n 1) sh
156156
docker rmi -f $(docker images -aq)
157157
```
158+
159+
### Documentation
160+
161+
The API docs are available at https://api.compassmeet.com. They are defined in [openapi.json](openapi.json).
162+
Just a few endpoints are mentioned in that JSON doc. Feel free to help by adding the remaining ones!

backend/api/src/app.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ swaggerDocument.info = {
113113
}
114114
};
115115

116-
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument))
117-
118-
app.listen(process.env.PORT ?? 8088, () => {
119-
console.log(`API UI available at /docs`)
120-
})
116+
app.use(pathWithPrefix(""), swaggerUi.serve, swaggerUi.setup(swaggerDocument))
121117

122118
app.options('*', allowCorsUnrestricted)
123119

@@ -171,7 +167,7 @@ const handlers: { [k in APIPath]: APIHandler<k> } = {
171167
Object.entries(handlers).forEach(([path, handler]) => {
172168
const api = API[path as APIPath]
173169
const cache = cacheController((api as any).cache)
174-
const url = '/' + pathWithPrefix(path as APIPath)
170+
const url = pathWithPrefix('/' + path as APIPath)
175171

176172
const apiRoute = [
177173
url,
@@ -193,11 +189,10 @@ Object.entries(handlers).forEach(([path, handler]) => {
193189
}
194190
})
195191

196-
console.log('COMPASS_API_KEY:', process.env.COMPASS_API_KEY)
192+
// console.log('COMPASS_API_KEY:', process.env.COMPASS_API_KEY)
197193

198194
// Internal Endpoints
199-
app.post(
200-
'/' + pathWithPrefix("internal/send-search-notifications"),
195+
app.post(pathWithPrefix("/internal/send-search-notifications"),
201196
async (req, res) => {
202197
const apiKey = req.header("x-api-key");
203198
if (apiKey !== process.env.COMPASS_API_KEY) {
@@ -223,7 +218,7 @@ app.use(allowCorsUnrestricted, (req, res) => {
223218
.status(404)
224219
.set('Content-Type', 'application/json')
225220
.json({
226-
message: `The requested route '${req.path}' does not exist. Please check your URL for any misspellings or refer to app.ts`,
221+
message: `This is the Compass API, but the requested route '${req.path}' does not exist. Please check your URL for any misspellings, the docs at https://api.compassmeet.com, or simply refer to app.ts on GitHub`,
227222
})
228223
}
229224
})

common/src/api/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class APIError extends Error {
2121
}
2222

2323
export function pathWithPrefix(path: string) {
24-
return `v0/${path}`
24+
return `/v0${path}`
2525
}
2626

2727
export function getWebsocketUrl() {

0 commit comments

Comments
 (0)