mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
Working on v3
This commit is contained in:
@@ -26,7 +26,8 @@
|
||||
"@adonisjs/auth",
|
||||
"@adonisjs/lucid",
|
||||
"@adonisjs/mail",
|
||||
"@adonisjs/view"
|
||||
"@adonisjs/view",
|
||||
"@adonisjs/ally"
|
||||
],
|
||||
"aceProviders": [
|
||||
"@adonisjs/repl"
|
||||
|
||||
@@ -29,3 +29,12 @@ CACHE_VIEWS=
|
||||
|
||||
MAILGUN_API_KEY=
|
||||
MAILGUN_URL=
|
||||
|
||||
GITHUB_CLIENT_ID=
|
||||
GITHUB_CLIENT_SECRET=
|
||||
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
|
||||
TWITTER_CLIENT_ID=
|
||||
TWITTER_CLIENT_SECRET=
|
||||
|
||||
24
app/Models/GoldenMessage.ts
Normal file
24
app/Models/GoldenMessage.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { DateTime } from 'luxon'
|
||||
import {BaseModel, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
||||
import User from "./User";
|
||||
import {BelongsTo} from "@ioc:Adonis/Lucid/Relations";
|
||||
|
||||
export default class GoldenMessage extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@belongsTo(() => User)
|
||||
public user: BelongsTo<typeof User>
|
||||
|
||||
@column()
|
||||
public userId: number
|
||||
|
||||
@column()
|
||||
public message: string
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
public createdAt: DateTime
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime
|
||||
}
|
||||
@@ -10,6 +10,9 @@ export default class User extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
public id: number
|
||||
|
||||
@column()
|
||||
public username: string
|
||||
|
||||
@column()
|
||||
public email: string
|
||||
|
||||
|
||||
56
config/ally.ts
Normal file
56
config/ally.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Config source: https://git.io/JOdi5
|
||||
*
|
||||
* Feel free to let us know via PR, if you find something broken in this config
|
||||
* file.
|
||||
*/
|
||||
|
||||
import Env from '@ioc:Adonis/Core/Env'
|
||||
import { AllyConfig } from '@ioc:Adonis/Addons/Ally'
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Ally Config
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The `AllyConfig` relies on the `SocialProviders` interface which is
|
||||
| defined inside `contracts/ally.ts` file.
|
||||
|
|
||||
*/
|
||||
const allyConfig: AllyConfig = {
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Github driver
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
github: {
|
||||
driver: 'github',
|
||||
clientId: Env.get('GITHUB_CLIENT_ID'),
|
||||
clientSecret: Env.get('GITHUB_CLIENT_SECRET'),
|
||||
callbackUrl: 'http://localhost:3333/github',
|
||||
},
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Twitter driver
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
twitter: {
|
||||
driver: 'twitter',
|
||||
clientId: Env.get('TWITTER_CLIENT_ID'),
|
||||
clientSecret: Env.get('TWITTER_CLIENT_SECRET'),
|
||||
callbackUrl: 'http://localhost:3333/twitter',
|
||||
},
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Google driver
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
google: {
|
||||
driver: 'google',
|
||||
clientId: Env.get('GOOGLE_CLIENT_ID'),
|
||||
clientSecret: Env.get('GOOGLE_CLIENT_SECRET'),
|
||||
callbackUrl: 'http://localhost:3333/google',
|
||||
},
|
||||
}
|
||||
|
||||
export default allyConfig
|
||||
23
contracts/ally.ts
Normal file
23
contracts/ally.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Contract source: https://git.io/JOdiQ
|
||||
*
|
||||
* Feel free to let us know via PR, if you find something broken in this contract
|
||||
* file.
|
||||
*/
|
||||
|
||||
declare module '@ioc:Adonis/Addons/Ally' {
|
||||
interface SocialProviders {
|
||||
github: {
|
||||
config: GithubDriverConfig
|
||||
implementation: GithubDriverContract
|
||||
}
|
||||
twitter: {
|
||||
config: TwitterDriverConfig
|
||||
implementation: TwitterDriverContract
|
||||
}
|
||||
google: {
|
||||
config: GoogleDriverConfig
|
||||
implementation: GoogleDriverContract
|
||||
}
|
||||
}
|
||||
}
|
||||
18
database/migrations/1621542488791_golden_messages.ts
Normal file
18
database/migrations/1621542488791_golden_messages.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class GoldenMessages extends BaseSchema {
|
||||
protected tableName = 'golden_messages'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.integer('user_id').notNullable()
|
||||
table.string('message')
|
||||
table.timestamps(true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
22
database/migrations/1621542495694_users.ts
Normal file
22
database/migrations/1621542495694_users.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
|
||||
export default class Users extends BaseSchema {
|
||||
protected tableName = 'users'
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary()
|
||||
table.string('username', 255).notNullable()
|
||||
table.string('email', 255).notNullable()
|
||||
table.string('password', 180).notNullable()
|
||||
table.boolean('is_confirmed').defaultTo(false).notNullable()
|
||||
table.string('remember_me_token').defaultTo(null).nullable()
|
||||
table.string('confirmation_token').defaultTo(null).nullable()
|
||||
table.timestamps(true)
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
10
env.ts
10
env.ts
@@ -53,4 +53,14 @@ export default Env.rules({
|
||||
//Mails
|
||||
MAILGUN_API_KEY: Env.schema.string(),
|
||||
MAILGUN_URL: Env.schema.string(),
|
||||
|
||||
//Socials Authentication
|
||||
GOOGLE_CLIENT_ID: Env.schema.string(),
|
||||
GOOGLE_CLIENT_SECRET: Env.schema.string(),
|
||||
|
||||
TWITTER_CLIENT_ID: Env.schema.string(),
|
||||
TWITTER_CLIENT_SECRET: Env.schema.string(),
|
||||
|
||||
GITHUB_CLIENT_ID: Env.schema.string(),
|
||||
GITHUB_CLIENT_SECRET: Env.schema.string(),
|
||||
})
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"youch-terminal": "^1.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@adonisjs/ally": "^3.2.1",
|
||||
"@adonisjs/auth": "^8.0.2",
|
||||
"@adonisjs/core": "~5.1.6",
|
||||
"@adonisjs/lucid": "^14.0.0",
|
||||
|
||||
4680
pnpm-lock.yaml
generated
Normal file
4680
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,7 @@
|
||||
"@adonisjs/lucid",
|
||||
"@adonisjs/mail",
|
||||
"@adonisjs/view",
|
||||
"@adonisjs/ally"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user