Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexnguyennz/solitosurrealdb
A Solito + SurrealDB basic starter incorporating Google authentication. Works on web (Next.js) and mobile (React Native & Expo)
https://github.com/alexnguyennz/solitosurrealdb
expo nextauth nextjs react react-native solito surrealdb
Last synced: 20 days ago
JSON representation
A Solito + SurrealDB basic starter incorporating Google authentication. Works on web (Next.js) and mobile (React Native & Expo)
- Host: GitHub
- URL: https://github.com/alexnguyennz/solitosurrealdb
- Owner: alexnguyennz
- Created: 2023-11-15T02:09:43.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-25T23:38:27.000Z (about 1 year ago)
- Last Synced: 2024-01-30T15:19:23.542Z (11 months ago)
- Topics: expo, nextauth, nextjs, react, react-native, solito, surrealdb
- Language: TypeScript
- Homepage: https://solito-surrealdb.vercel.app
- Size: 2.07 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Solito SurrealDB
## Setup
**Web**
1. Create OAuth Client ID of `Web` type
```
// Authorized Origin
https://nextjsappname.vercel.app// Authorized Redirect URIs
http://localhost:3000/api/auth/callback/google
https://nextjsappname.vercel.app/auth/callback/google
```
2. Copy client ID and secret for Next.js environment variables**Android**
1. Create OAuth Client ID of `Android` type
2. Copy package name from `/apps/expo/app.json` e.g. `com.anonymous.solitoexporouter` and enter in configuration
3. cd into `/apps/expo/android` and run `keytool -keystore app/debug.keystore -list -v`
4. use password of `android`
5. copy SHA1 into configuration
4. Add your testing Google account email under "OAuth consent screen" as a test user### Expo
**.env** (/apps/expo)
```
// change local IP address to your own
// change to live domain in production
EXPO_PUBLIC_API_URL=http://192.168.1.68:3000EXPO_PUBLIC_GOOGLE_CLIENT_ID=webGoogleClientID
```### Next.js
**.env.local** (/apps/next)
```
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=mysecret// change to live database in production
SURREAL_ENDPOINT=http://localhost:8000// change accordingly
SURREAL_NAMESPACE=test
SURREAL_DATABASE=test
SURREAL_USERNAME=root
SURREAL_PASSWORD=rootGOOGLE_CLIENT_ID=webGoogleClientID
GOOGLE_CLIENT_SECRET=webGoogleClientSecret
```### Installation and Development
1. Run `yarn install`
2. In two terminals:
3. cd into `apps/expo` and run `npx expo ios:android`
4. run `yarn web` for Next.js### SurrealDB
**Setup**
1. Run below schema in SurrealDB**Schema**
```sql
DEFINE TABLE users SCHEMAFULL
PERMISSIONS
FOR select, update, delete WHERE id = $auth.id;DEFINE FIELD sub ON users TYPE string;
DEFINE FIELD name ON users TYPE string;
DEFINE FIELD email ON users TYPE string ASSERT string::is::email($value);
DEFINE FIELD picture ON users TYPE string;DEFINE INDEX sub ON users COLUMNS sub UNIQUE;
DEFINE INDEX email ON users FIELDS email UNIQUE;DEFINE SCOPE users
SESSION 1d
SIGNUP (CREATE users SET sub = $sub, email = $email, name = $name, picture = $picture)
SIGNIN (SELECT * FROM users WHERE sub = $sub AND email = $email)
;DEFINE TABLE posts SCHEMAFULL
PERMISSIONS
FOR create, update, delete WHERE users = $auth.id;DEFINE FIELD content on posts TYPE string;
DEFINE FIELD users ON posts TYPE record (users) ASSERT $value IS NOT NONE;
```