feat: Toggle reviews via ENV
This commit is contained in:
@ -36,10 +36,11 @@ Docker is coming soon!
|
||||
3. Launch the app at `src/main.ts` with the environment variables set:
|
||||
- `GOOGLE_GENERATIVE_AI_API_KEY` (optional, to enable MapAI features. Its free at Google!)
|
||||
- `TANKERKOENIG_API_KEY` (optional, to enable fuel price features. Its free!)
|
||||
- `OIDC_ENABLED` (required to be set to `true`)
|
||||
- `OIDC_ENABLED` (needs to be enabled for most features requiring authentication)
|
||||
- `OIDC_AUTH_URL` (the Authentication URL of your OIDC server)
|
||||
- `OIDC_CLIENT_ID` (the Client ID of your OIDC server)
|
||||
- `OIDC_TOKEN_URL` (the Token URL of your OIDC server)
|
||||
- `OIDC_JWKS_URL` (the JWKS/Certificate URL of your OIDC server)
|
||||
- `REVIEWS_ENABLED` (optional, set to `true` to enable POI reviews by users, requires OIDC)
|
||||
|
||||
When configuring your OIDC server, make sure to enable Public Client and PCKE support.
|
||||
|
12
src/main.ts
12
src/main.ts
@ -41,7 +41,15 @@ app.use(
|
||||
);
|
||||
|
||||
app.get("/api/config", (c) => {
|
||||
const capabilities: string[] = ["auth", "reviews"];
|
||||
const capabilities: string[] = [];
|
||||
|
||||
if(process.env.OIDC_ENABLED) {
|
||||
capabilities.push("auth");
|
||||
}
|
||||
|
||||
if(process.env.REVIEWS_ENABLED) {
|
||||
capabilities.push("reviews");
|
||||
}
|
||||
|
||||
if(process.env.GOOGLE_GENERATIVE_AI_API_KEY) {
|
||||
capabilities.push("ai");
|
||||
@ -63,6 +71,7 @@ app.get("/api/config", (c) => {
|
||||
})
|
||||
})
|
||||
|
||||
if(process.env.REVIEWS_ENABLED) {
|
||||
app.get("/api/reviews", async (c) => {
|
||||
let {lat, lon} = c.req.query();
|
||||
if (!lat || !lon) {
|
||||
@ -119,6 +128,7 @@ app.post("/api/review", async (c) => {
|
||||
|
||||
return c.json(res.rows[0]);
|
||||
})
|
||||
}
|
||||
|
||||
if(process.env.TANKERKOENIG_API_KEY) {
|
||||
app.get("/api/fuel/list", async (c) => {
|
||||
|
Reference in New Issue
Block a user