WaspW
Wasp2y ago
fred-123

How to create a custom API Endpoint to check subscriptionStatus and subscriptionTier

I am building a browser extension that should only be accessible to the users that have an account with my webapp and are logged in with the same browser.

My wasp version seems to be 0.13.2 as it returns that when I run wasp version.

I have noticed that wasp documentation mentions this in the documentation for wasp 0.13:
https://wasp-lang.dev/docs/advanced/apis#api-reference

api fooBar { // APIs and their implementations don't need to (but can) have the same name.
fn: import { fooBar } from "@src/apis",
httpRoute: (GET, "/foo/bar")
}

and for queries:


query getAllTasks {
fn: import { getAllTasks } from "@src/queries.js"
}

query getFilteredTasks {
fn: import { getFilteredTasks } from "@src/queries.js"
}


Anyhow, I have noticed that my default set up queries use a different path:

query getDailyStats {
fn: import { getDailyStats } from "@src/server/queries.js",
entities: [User, DailyStats]
}

I can't make custom endpoints work and have been trying for an entire day now.

Calls like this one work without a problem though: http://localhost:3001/auth/email/login

My Questoins are the following:

Is it correct to have quereis.ts and actions.ts at these paths when on wasp 0.13?

app/src/server/queries.ts
app/src/server/actions.ts

Is there already a build in way to check if somebody is a subscribed user?
Am i missing something obvious here?

Thank you in advance for any help! This is doing my head in.
In Wasp, the default client-server interaction mechanism is through Operations. However, if you need a specific URL method/path, or a specific response, Operations may not be suitable for you. For these cases, you can use an api. Best of all, they should look and feel very familiar.
Was this page helpful?