-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a recipeModule manager #16
Comments
Routing functionalityimport * as supertokens from "supertokens-node";
let app = express();
app.use(supertokens.middleware());
app.use(supertokens.errorHandler()); |
If a recipe is being built on top of another one, how can its rId be propogated down?Base recipeclass EmailPassword extends RecipeModule {
static instance: undefined | EmailPassword
static getInstanceOrThrowError() => {
if (instance !== undefined) {
return instance;
}
throw error("please call init..");
}
static init(options: {..}): ModuleInterface {
constructor(options, "emailpassword")
// create a singleton instance of EmailPassword
}
constructor({..}, recipeId) {
super(recipeId)
....
}
signUp(email, password) {
let rId = super.getRecipeId();
// do implementation...
}
static signUp(email, password) => {
let instance = EmailPassword.__getInstanceIfDefined();
return await instance.signUp(email, passowrd);
}
} New recipeclass EmailPasswordModified extends RecipeModule {
static instance: undefined | EmailPasswordModified
emailPasswordInstance: EmailPassword
constructor({..}, recipeId) {
super(recipeId)
this.emailPasswordInstance = new EmailPassword(<options specific to this>, recipeId)
}
static getInstanceOrThrowError() => {
if (instance !== undefined) {
return instance;
}
throw error("please call init..");
}
static init(options: {..}): ModuleInterface {
constructor(options, "emailpasswordmodified")
}
static signUp(email, password) => {
let instance = EmailPasswordModified.__getInstanceIfDefined();
return await instance.emailPasswordInstance.signUp(email, passowrd)
}
} Edit:
|
In the config for This implies that the |
The routing algorithm:
@NkxxkN , I have written the routing algo in a bit more detail here (in comparison to the one written in the frontend package). It still follows the same login though. Lmk if this is fine with you and if you have done something very differently on the frontend. |
Do you loop through recipes and then through features? i.e. where and how do you store the routes? what's the data structure for it? Seems to be working from a logic perspective! |
The routing code is here The notion of a feature is slightly loose in the backend since it's just a bunch of functions and APIs being exposed by each feature. So there isn't really a concept of an explicit feature like there is on the frontend (cause frontend features are much more complex and have themes)
The
The actual recipe implements this function to return the array of these objects - one per support API / route. |
Ok looks good to me! |
@NkxxkN. I am done with this issue. The PR is #25, but since it's a complete rewrite of most of the lib anyway, I am pushing it to branch |
Should be responsible for:
Routing of an API to a module. The algorithm can be found here
Has a way for any module to get the
appInfo
if needed.Has an init function that takes:
hosts
andapiKey
Has error handling routing for modules:
rId
:Handle CORS headers. Has a function like
getAllCORSHeaders
which:getAllCORSHeaders
for each modulestrings
in an arrayProvides an abstract
recipeModule
class that modules must extend:apiBasePath
) via the middleware function.rId
. TherId
will be an argument to the constructor.Recipe modules must be built such that parent recipe's rId can be propagated to them. This is how
Enforce use of
NormalisedURLDomain
andNormalisedURLPath
The text was updated successfully, but these errors were encountered: