Skip to content

Commit

Permalink
🚀 Add emails and basic google auth
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGlox committed Jun 16, 2024
1 parent bbd2865 commit da35ee8
Show file tree
Hide file tree
Showing 67 changed files with 2,931 additions and 100 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ DB_USER=postgres
DB_PASSWORD=
DB_DATABASE=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CLIENT_SECRET=
SMTP_HOST=
SMTP_PORT=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
node_modules
build
tmp
.adonisjs

# Secrets
.env
Expand Down
9 changes: 8 additions & 1 deletion adonisrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export default defineConfig({
| will be scanned automatically from the "./commands" directory.
|
*/
commands: [() => import('@adonisjs/core/commands'), () => import('@adonisjs/lucid/commands')],
commands: [
() => import('@adonisjs/core/commands'),
() => import('@adonisjs/lucid/commands'),
() => import('@tuyau/core/commands'),
() => import('@adonisjs/mail/commands'),
],

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -40,6 +45,8 @@ export default defineConfig({
() => import('@adonisjs/inertia/inertia_provider'),
() => import('@adonisjs/i18n/i18n_provider'),
() => import('@adonisjs/ally/ally_provider'),
() => import('@tuyau/core/tuyau_provider'),
() => import('@adonisjs/mail/mail_provider'),
],

/*
Expand Down
17 changes: 17 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "resources/css/globals.css",
"baseColor": "zinc",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "resources/components",
"utils": "resources/lib/utils"
}
}
14 changes: 14 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
database:
image: postgres:16-alpine3.19
ports:
- "5432:5432"
volumes:
- psql-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres

volumes:
psql-data:
8 changes: 7 additions & 1 deletion config/ally.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ const allyConfig = defineConfig({
google: services.google({
clientId: env.get('GOOGLE_CLIENT_ID'),
clientSecret: env.get('GOOGLE_CLIENT_SECRET'),
callbackUrl: '',
callbackUrl: 'http://localhost:3333/google/callback',
// Google specific
prompt: 'select_account',
accessType: 'offline',
hostedDomain: 'localhost',
display: 'page',
scopes: ['userinfo.email', 'userinfo.profile'],
}),
})

Expand Down
12 changes: 10 additions & 2 deletions config/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ import { defineConfig } from '@adonisjs/cors'
*/
const corsConfig = defineConfig({
enabled: true,
origin: [],
origin: '*',
methods: ['GET', 'HEAD', 'POST', 'PUT', 'DELETE'],
headers: true,
exposeHeaders: [],
exposeHeaders: [
'access-control-allow-origin',
'cache-control',
'content-language',
'content-type',
'expires',
'last-modified',
'pragma',
],
credentials: true,
maxAge: 90,
})
Expand Down
1 change: 0 additions & 1 deletion config/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const i18nConfig = defineConfig({
formatter: formatters.icu(),
supportedLocales: ['en', 'fr'],
fallbackLocales: {
'en-UK': 'en',
'en-US': 'en',
'fr-FR': 'fr',
},
Expand Down
2 changes: 2 additions & 0 deletions config/inertia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export default defineConfig({
* Data that should be shared with all rendered pages
*/
sharedData: {
alert: (ctx) => ctx.session?.flashMessages.get('alert'),
errors: (ctx) => ctx.session?.flashMessages.get('errors'),
i18n: (ctx) => ctx.i18n,
},

/**
Expand Down
33 changes: 33 additions & 0 deletions config/mail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import env from '#start/env'
import { defineConfig, transports } from '@adonisjs/mail'

const mailConfig = defineConfig({
default: 'smtp',

/**
* The mailers object can be used to configure multiple mailers
* each using a different transport or same transport with different
* options.
*/
mailers: {
smtp: transports.smtp({
host: env.get('SMTP_HOST'),
port: env.get('SMTP_PORT'),
/**
* Uncomment the auth block if your SMTP
* server needs authentication
*/
/* auth: {
type: 'login',
user: env.get('SMTP_USERNAME'),
pass: env.get('SMTP_PASSWORD'),
}, */
}),
},
})

export default mailConfig

declare module '@adonisjs/mail/types' {
export interface MailersList extends InferMailers<typeof mailConfig> {}
}
17 changes: 17 additions & 0 deletions config/tuyau.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from '@tuyau/core'

const tuyauConfig = defineConfig({
codegen: {
/**
* Filters the definitions and named routes to be generated
*/
// definitions: {
// only: [],
// }
// routes: {
// only: [],
// }
},
})

export default tuyauConfig
21 changes: 0 additions & 21 deletions database/migrations/1717452976737_create_posts_table.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ export default class extends BaseSchema {

async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.uuid('id').primary().defaultTo(this.db.rawQuery('gen_random_uuid()').knexQuery)

table.timestamp('created_at')
table.timestamp('updated_at')

table.string('full_name')
table.string('email').unique().notNullable()
table.string('password').notNullable()
table.timestamp('created_at')
table.timestamp('updated_at')
})
}

Expand Down
12 changes: 12 additions & 0 deletions database/seeders/user_seeder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { User } from '#src/users/models/user'
import { BaseSeeder } from '@adonisjs/lucid/seeders'

export default class extends BaseSeeder {
async run() {
// Write your database queries inside the run method
await User.create({
email: 'contact@morgan-leroux.com',
password: 'testtest',
})
}
}
25 changes: 22 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
},
"imports": {
"#app/*": "./app/*.js",
"#components/*": "./resources/components/*.js",
"#containers/*": "./resources/containers/*.js",
"#core/*": "./src/core/*.js",
"#resources/*": "./resources/*.js",
"#src/*": "./src/*.js",
Expand All @@ -33,7 +35,7 @@
"@japa/runner": "^3.1.4",
"@swc/core": "^1.5.7",
"@types/luxon": "^3.4.2",
"@types/node": "^20.12.12",
"@types/node": "^20.13.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.0",
Expand All @@ -46,7 +48,8 @@
"tailwindcss": "^3.4.3",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"vite": "^5.2.11"
"vite": "^5.2.11",
"vite-plugin-svgr": "^4.2.0"
},
"dependencies": {
"@adonisjs/ally": "^5.0.2",
Expand All @@ -56,18 +59,34 @@
"@adonisjs/i18n": "^2.1.0",
"@adonisjs/inertia": "1.0.0-27",
"@adonisjs/lucid": "^20.6.0",
"@adonisjs/mail": "^9.2.1",
"@adonisjs/session": "^7.4.0",
"@adonisjs/shield": "^8.1.1",
"@adonisjs/static": "^1.1.1",
"@adonisjs/vite": "^3.0.0-11",
"@inertiajs/react": "^1.1.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"@tuyau/client": "^0.1.2",
"@tuyau/core": "^0.1.4",
"@vinejs/vine": "^2.0.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"edge.js": "^6.0.2",
"i18next": "^23.11.5",
"lucide-react": "^0.394.0",
"luxon": "^3.4.4",
"mjml": "^4.15.3",
"pg": "^8.11.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"reflect-metadata": "^0.2.2"
"react-i18next": "^14.1.2",
"reflect-metadata": "^0.2.2",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7"
},
"hotHook": {
"boundaries": [
Expand Down
Loading

0 comments on commit da35ee8

Please sign in to comment.