Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Bindable Microservices. This contribution is the first in this direction where templates are provided out of the box to help kickstart development in a few simple steps, in a way that you can have ownership to control and modify application logic to fit the needs of your project. As the first exploratory template, we're introducing basic user authentication.
username
oremail
and apassword
When it comes to making subsequent requests with authentication, you will need to check the users session is valid & active yourself. We did not implement this by default out of the box due to the unknowing of how each application will handle the middleware aspects. However, an example/available
isSessionValid
function is available for you to reference on how to verify sessions.The objective with StarbaseDB is to provide essential tooling developers need as close to their database as possible without any additional effort. We believe Bindable Microservices is a step in that direction.
Tasks
Execute SQL statements in
migration.sql
to create required tablesThis will create the tables and constraints for user signup/login, and sessions. You can do this in the Studio user interface or by hitting your query endpoint in your StarbaseDB instance.
Add service bindings to wrangler.toml
Add AUTH to Env interface in
./src/index.ts
Add routing logic in default export in
./src/index.ts
Deploy template project to Cloudflare
Deploy updates to StarbaseDB to Cloudflare
NOTE: You will want to deploy your new service worker for authentication before deploying updates to your StarbaseDB instance, because the StarbaseDB instance will rely on the authentication worker being available (see the service bindings we added in the wrangler.toml file for reference).
Verify
Before
After