@auth/edgedb-adapter
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -11,3 +11,3 @@ /** | ||
* | ||
* ```bash npm2yarn2pnpm | ||
* ```bash npm2yarn | ||
* npm install edgedb @auth/edgedb-adapter | ||
@@ -25,3 +25,3 @@ * npm install @edgedb/generate --save-dev | ||
* | ||
* ```bash npm2yarn2pnpm | ||
* ```bash npm2yarn | ||
* npm install edgedb @auth/edgedb-adapter | ||
@@ -86,3 +86,3 @@ * npm install @edgedb/generate --save-dev | ||
* | ||
* > This schema is adapted for use in EdgeDB and based upon our main [schema](/adapters/models) | ||
* > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models) | ||
* | ||
@@ -181,3 +181,3 @@ * ```json title="default.esdl" | ||
* | ||
* ```npm2yarn2pnpm | ||
* ```npm2yarn | ||
* npx @edgedb/generate edgeql-js | ||
@@ -184,0 +184,0 @@ * ``` |
@@ -11,3 +11,3 @@ /** | ||
* | ||
* ```bash npm2yarn2pnpm | ||
* ```bash npm2yarn | ||
* npm install edgedb @auth/edgedb-adapter | ||
@@ -23,3 +23,3 @@ * npm install @edgedb/generate --save-dev | ||
* | ||
* ```bash npm2yarn2pnpm | ||
* ```bash npm2yarn | ||
* npm install edgedb @auth/edgedb-adapter | ||
@@ -84,3 +84,3 @@ * npm install @edgedb/generate --save-dev | ||
* | ||
* > This schema is adapted for use in EdgeDB and based upon our main [schema](/adapters/models) | ||
* > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models) | ||
* | ||
@@ -179,3 +179,3 @@ * ```json title="default.esdl" | ||
* | ||
* ```npm2yarn2pnpm | ||
* ```npm2yarn | ||
* npx @edgedb/generate edgeql-js | ||
@@ -182,0 +182,0 @@ * ``` |
{ | ||
"name": "@auth/edgedb-adapter", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "EdgeDB adapter for next-auth.", | ||
@@ -40,3 +40,3 @@ "homepage": "https://authjs.dev", | ||
"dependencies": { | ||
"@auth/core": "0.18.0" | ||
"@auth/core": "0.18.1" | ||
}, | ||
@@ -47,8 +47,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@auth/adapter-test": "^0.0.0", | ||
"@auth/tsconfig": "^0.0.0", | ||
"jest": "^27.4.3", | ||
"typescript": "^4.7.4", | ||
"edgedb": "^1.0.1", | ||
"@auth/core": "0.18.0" | ||
"edgedb": "^1.0.1" | ||
}, | ||
@@ -55,0 +50,0 @@ "jest": { |
146
src/index.ts
@@ -11,3 +11,3 @@ /** | ||
* | ||
* ```bash npm2yarn2pnpm | ||
* ```bash npm2yarn | ||
* npm install edgedb @auth/edgedb-adapter | ||
@@ -29,16 +29,16 @@ * npm install @edgedb/generate --save-dev | ||
/** | ||
* | ||
* | ||
* To use this Adapter, you need to install `edgedb`, `@edgedb/generate`, and the separate `@auth/edgedb-adapter` package: | ||
* | ||
* ```bash npm2yarn2pnpm | ||
* | ||
* ```bash npm2yarn | ||
* npm install edgedb @auth/edgedb-adapter | ||
* npm install @edgedb/generate --save-dev | ||
* ``` | ||
* | ||
* | ||
* ## Installation | ||
* | ||
* First, ensure you have the EdgeDB CLI installed. | ||
* | ||
* | ||
* First, ensure you have the EdgeDB CLI installed. | ||
* | ||
* Follow the instructions below, or read the [EdgeDB quickstart](https://www.edgedb.com/docs/intro/quickstart) to install the EdgeDB CLI and initialize a project | ||
* | ||
* | ||
* ### Linux or macOS | ||
@@ -48,3 +48,3 @@ * ```bash | ||
* ``` | ||
* | ||
* | ||
* ### Windows | ||
@@ -54,19 +54,19 @@ * ```powershell | ||
* ``` | ||
* | ||
* | ||
* Check that the CLI is available with the `edgedb --version` command. If you get a `Command not found` error, you may need to open a new terminal window before the `edgedb` command is available. | ||
* | ||
* | ||
* Once the CLI is installed, initialize a project from the application’s root directory. You’ll be presented with a series of prompts. | ||
* | ||
* | ||
* ```bash | ||
* edgedb project init | ||
* ``` | ||
* | ||
* | ||
* This process will spin up an EdgeDB instance and [“link”](https://www.edgedb.com/docs/cli/edgedb_instance/edgedb_instance_link#edgedb-instance-link) it with your current directory. As long as you’re inside that directory, CLI commands and client libraries will be able to connect to the linked instance automatically, without additional configuration. | ||
* | ||
* | ||
* ## Setup | ||
* | ||
* | ||
* ### NextAuth.js configuration | ||
* | ||
* | ||
* Configure your NextAuth.js to use the EdgeDB Adapter: | ||
* | ||
* | ||
* ```javascript title="pages/api/auth/[...nextauth].js" | ||
@@ -77,5 +77,5 @@ * import NextAuth from "next-auth" | ||
* import { createClient } from "edgedb" | ||
* | ||
* | ||
* const client = createClient() | ||
* | ||
* | ||
* export default NextAuth({ | ||
@@ -91,9 +91,9 @@ * adapter: EdgeDBAdapter(client), | ||
* ``` | ||
* | ||
* | ||
* ### Create the EdgeDB schema | ||
* | ||
* | ||
* Replace the contents of the auto-generated file in `dbschema/default.esdl` with the following: | ||
* | ||
* > This schema is adapted for use in EdgeDB and based upon our main [schema](/adapters/models) | ||
* | ||
* > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models) | ||
* | ||
* ```json title="default.esdl" | ||
@@ -109,3 +109,3 @@ * module default { | ||
* multi link accounts := .<user[is Account]; | ||
* multi link sessions := .<user[is Session]; | ||
* multi link sessions := .<user[is Session]; | ||
* property createdAt -> datetime { | ||
@@ -115,3 +115,3 @@ * default := datetime_current(); | ||
* } | ||
* | ||
* | ||
* type Account { | ||
@@ -137,6 +137,6 @@ * required property userId := .user.id; | ||
* }; | ||
* | ||
* | ||
* constraint exclusive on ((.provider, .providerAccountId)) | ||
* } | ||
* | ||
* | ||
* type Session { | ||
@@ -155,3 +155,3 @@ * required property sessionToken -> str { | ||
* } | ||
* | ||
* | ||
* type VerificationToken { | ||
@@ -166,7 +166,7 @@ * required property identifier -> str; | ||
* }; | ||
* | ||
* | ||
* constraint exclusive on ((.identifier, .token)) | ||
* } | ||
* } | ||
* | ||
* | ||
* # Disable the application of access policies within access policies | ||
@@ -177,29 +177,29 @@ * # themselves. This behavior will become the default in EdgeDB 3.0. | ||
* ``` | ||
* | ||
* | ||
* ### Migrate the database schema | ||
* | ||
* | ||
* Create a migration | ||
* | ||
* | ||
* ``` | ||
* edgedb migration create | ||
* ``` | ||
* | ||
* | ||
* Apply the migration | ||
* | ||
* | ||
* ``` | ||
* edgedb migrate | ||
* ``` | ||
* | ||
* | ||
* To learn more about [EdgeDB migrations](https://www.edgedb.com/docs/intro/migrations#generate-a-migration), check out the [Migrations docs](https://www.edgedb.com/docs/intro/migrations). | ||
* | ||
* | ||
* ### Generate the query builder | ||
* | ||
* ```npm2yarn2pnpm | ||
* | ||
* ```npm2yarn | ||
* npx @edgedb/generate edgeql-js | ||
* ``` | ||
* | ||
* | ||
* This will generate the [query builder](https://www.edgedb.com/docs/clients/js/querybuilder) so that you can write fully typed EdgeQL queries with TypeScript in a code-first way. | ||
* | ||
* | ||
* For example | ||
* | ||
* | ||
* ```ts | ||
@@ -214,5 +214,5 @@ * const query = e.select(e.User, () => ({ | ||
* })); | ||
* | ||
* | ||
* return await query.run(client); | ||
* | ||
* | ||
* // Return type: | ||
@@ -226,36 +226,36 @@ * // { | ||
* // } | null | ||
* | ||
* | ||
* ``` | ||
* | ||
* | ||
* | ||
* | ||
* ## Deploying | ||
* | ||
* | ||
* ### Deploy EdgeDB | ||
* | ||
* | ||
* First deploy an EdgeDB instance on your preferred cloud provider: | ||
* | ||
* | ||
* [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs) | ||
* | ||
* | ||
* [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp) | ||
* | ||
* | ||
* [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver) | ||
* | ||
* | ||
* [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean) | ||
* | ||
* | ||
* [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io) | ||
* | ||
* | ||
* [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic) | ||
* | ||
* | ||
* ### Find your instance’s DSN | ||
* | ||
* | ||
* The DSN is also known as a connection string. It will have the format `edgedb://username:password@hostname:port`. The exact instructions for this depend on which cloud you are deploying to. | ||
* | ||
* | ||
* ### Set an environment variable | ||
* | ||
* | ||
* ```env title=".env" | ||
* EDGEDB_DSN=edgedb://johndoe:supersecure@myhost.com:420 | ||
* ``` | ||
* | ||
* | ||
* ### Update the client | ||
* | ||
* | ||
* ```diff title="pages/api/auth/[...nextauth].js" | ||
@@ -266,6 +266,6 @@ * import NextAuth from "next-auth" | ||
* import { createClient } from "edgedb" | ||
* | ||
* | ||
* - const client = createClient() | ||
* + const client = createClient({ dsn: process.env.EDGEDB_DSN }) | ||
* | ||
* | ||
* export default NextAuth({ | ||
@@ -281,17 +281,17 @@ * adapter: EdgeDBAdapter(client), | ||
* ``` | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* ### Apply migrations | ||
* | ||
* | ||
* Use the DSN to apply migrations against your remote instance. | ||
* | ||
* | ||
* ```bash | ||
* edgedb migrate --dsn <your-instance-dsn> | ||
* ``` | ||
* | ||
* | ||
* ### Set up a `prebuild` script | ||
* | ||
* | ||
* Add the following `prebuild` script to your `package.json`. When your hosting provider initializes the build, it will trigger this script which will generate the query builder. The `npx @edgedb/generate edgeql-js` command will read the value of the `EDGEDB_DSN` environment variable, connect to the database, and generate the query builder before your hosting provider starts building the project. | ||
* | ||
* | ||
* ```diff title="package.json" | ||
@@ -306,3 +306,3 @@ * "scripts": { | ||
* ``` | ||
* | ||
* | ||
*/ | ||
@@ -309,0 +309,0 @@ export function EdgeDBAdapter(client: Client): Adapter { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
46700
+ Added@auth/core@0.18.1(transitive)
+ Addedjose@5.9.6(transitive)
- Removed@auth/core@0.18.0(transitive)
- Removedjose@4.15.9(transitive)
Updated@auth/core@0.18.1