mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
Lint and update
This commit is contained in:
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
nodes_modules
|
||||||
|
.env
|
||||||
|
build
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Announce from "App/Models/Announce";
|
import Announce from 'App/Models/Announce'
|
||||||
import AnnounceUpdateValidator from "App/Validators/announce/AnnounceUpdateValidator";
|
import AnnounceUpdateValidator from 'App/Validators/announce/AnnounceUpdateValidator'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class AnnouncesController {
|
export default class AnnouncesController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const announce = await Announce
|
const announce = await Announce
|
||||||
.query()
|
.query()
|
||||||
.orderBy('created_at', 'desc')
|
.orderBy('created_at', 'desc')
|
||||||
@@ -14,17 +13,16 @@ export default class AnnouncesController {
|
|||||||
.preload('cover')
|
.preload('cover')
|
||||||
.first()
|
.first()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
announce: announce
|
announce,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const data = await request.validate(AnnounceUpdateValidator)
|
const data = await request.validate(AnnounceUpdateValidator)
|
||||||
const announce = await Announce.findOrFail(params.id)
|
const announce = await Announce.findOrFail(params.id)
|
||||||
|
|
||||||
if (data.code) {
|
if (data.code)
|
||||||
await announce.related('message').associate(await getTranslation(data.code))
|
await announce.related('message').associate(await getTranslation(data.code))
|
||||||
}
|
|
||||||
|
|
||||||
const cover = await File.findBy('label', data.cover)
|
const cover = await File.findBy('label', data.cover)
|
||||||
if (cover) await announce.related('cover').associate(cover)
|
if (cover) await announce.related('cover').associate(cover)
|
||||||
@@ -32,8 +30,7 @@ export default class AnnouncesController {
|
|||||||
await announce.merge(data).save()
|
await announce.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
announce
|
announce,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,52 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import AuthValidator from "App/Validators/AuthValidator";
|
import AuthValidator from 'App/Validators/AuthValidator'
|
||||||
|
|
||||||
export default class AuthController {
|
export default class AuthController {
|
||||||
|
public async loginApi({ request, auth, response }: HttpContextContract) {
|
||||||
public async loginApi ({ request, auth, response }: HttpContextContract) {
|
|
||||||
const { email, password } = await request.validate(AuthValidator)
|
const { email, password } = await request.validate(AuthValidator)
|
||||||
const token = await auth.use('api').attempt(email, password, {
|
const token = await auth.use('api').attempt(email, password, {
|
||||||
expiresIn: '2 days'
|
expiresIn: '2 days',
|
||||||
})
|
})
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
token: token.toJSON()
|
token: token.toJSON(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async loginWeb ({ request, auth, response }: HttpContextContract) {
|
public async loginWeb({ request, auth, response }: HttpContextContract) {
|
||||||
const { email, password, remember } = await request.validate(AuthValidator)
|
const { email, password, remember } = await request.validate(AuthValidator)
|
||||||
await auth.use('web').attempt(email, password, remember)
|
await auth.use('web').attempt(email, password, remember)
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
user: auth.use('web').user
|
user: auth.use('web').user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createInfiniteToken ({ request, auth, response }: HttpContextContract) {
|
public async createInfiniteToken({ request, auth, response }: HttpContextContract) {
|
||||||
const { email, password } = await request.validate(AuthValidator)
|
const { email, password } = await request.validate(AuthValidator)
|
||||||
const token = await auth.use('api').attempt(email, password)
|
const token = await auth.use('api').attempt(email, password)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
token: token.toJSON()
|
token: token.toJSON(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async logoutApi ({ auth, response }: HttpContextContract) {
|
public async logoutApi({ auth, response }: HttpContextContract) {
|
||||||
await auth.use('api').revoke()
|
await auth.use('api').revoke()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'You have been disconnected!'
|
message: 'You have been disconnected!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async logoutWeb ({ auth, response }: HttpContextContract) {
|
public async logoutWeb({ auth, response }: HttpContextContract) {
|
||||||
await auth.use('web').logout()
|
await auth.use('web').logout()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'You have been disconnected!'
|
message: 'You have been disconnected!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async user ({ auth, response }: HttpContextContract) {
|
public async user({ auth, response }: HttpContextContract) {
|
||||||
const user = await auth.use('web').authenticate() || await auth.use('api').authenticate()
|
const user = await auth.use('web').authenticate() || await auth.use('api').authenticate()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
user
|
user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +1,57 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Experience from "App/Models/Experience";
|
import Experience from 'App/Models/Experience'
|
||||||
import ExperienceStoreValidator from "App/Validators/experience/ExperienceStoreValidator";
|
import ExperienceStoreValidator from 'App/Validators/experience/ExperienceStoreValidator'
|
||||||
import ExperienceUpdateValidator from "App/Validators/experience/ExperienceUpdateValidator";
|
import ExperienceUpdateValidator from 'App/Validators/experience/ExperienceUpdateValidator'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class ExperiencesController {
|
export default class ExperiencesController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const experiences = await Experience
|
const experiences = await Experience
|
||||||
.query()
|
.query()
|
||||||
.orderBy('begin_date', 'desc')
|
.orderBy('begin_date', 'desc')
|
||||||
.preload('title')
|
.preload('title')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
experiences: experiences
|
experiences,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(ExperienceStoreValidator)
|
const data = await request.validate(ExperienceStoreValidator)
|
||||||
const experience = await Experience.create(data)
|
const experience = await Experience.create(data)
|
||||||
await experience.related('title').associate(await getTranslation(data.title))
|
await experience.related('title').associate(await getTranslation(data.title))
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
experience: experience
|
experience,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
const experience = await Experience.findOrFail(params.id)
|
const experience = await Experience.findOrFail(params.id)
|
||||||
experience.load('title')
|
experience.load('title')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
experience
|
experience,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const data = await request.validate(ExperienceUpdateValidator)
|
const data = await request.validate(ExperienceUpdateValidator)
|
||||||
const experience = await Experience.findOrFail(params.id)
|
const experience = await Experience.findOrFail(params.id)
|
||||||
|
|
||||||
if (data.title) {
|
if (data.title)
|
||||||
await experience.related('title').associate(await getTranslation(data.title))
|
await experience.related('title').associate(await getTranslation(data.title))
|
||||||
}
|
|
||||||
|
|
||||||
await experience.merge(data).save()
|
await experience.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
experience
|
experience,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const experience = await Experience.findOrFail(params.id)
|
const experience = await Experience.findOrFail(params.id)
|
||||||
await experience.delete()
|
await experience.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Experience successfully deleted!'
|
message: 'Experience successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,46 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Application from "@ioc:Adonis/Core/Application";
|
import Application from '@ioc:Adonis/Core/Application'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
|
|
||||||
export default class FilesController {
|
export default class FilesController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
files: await File.all()
|
files: await File.all(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const file = await request.file('file', {
|
const file = await request.file('file', {
|
||||||
extnames: ['jpg', 'png', 'jpeg']
|
extnames: ['jpg', 'png', 'jpeg'],
|
||||||
})
|
})
|
||||||
const label = request.input('label')
|
const label = request.input('label')
|
||||||
|
|
||||||
if (!file) {
|
if (!file)
|
||||||
return 'Please upload file!'
|
return 'Please upload file!'
|
||||||
}
|
|
||||||
if (file.hasErrors) {
|
if (file.hasErrors)
|
||||||
return file.errors
|
return file.errors
|
||||||
}
|
|
||||||
|
|
||||||
await file.move(Application.makePath('storage'), {
|
await file.move(Application.makePath('storage'), {
|
||||||
name: `${label}.${file.extname}`,
|
name: `${label}.${file.extname}`,
|
||||||
overwrite: true
|
overwrite: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
file: await File.firstOrCreate({
|
file: await File.firstOrCreate({
|
||||||
label: label
|
label,
|
||||||
}, {
|
}, {
|
||||||
fileName: `${label}.${file.extname}`,
|
fileName: `${label}.${file.extname}`,
|
||||||
label: label
|
label,
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ params, response }: HttpContextContract) {
|
public async destroy({ params, response }: HttpContextContract) {
|
||||||
const file = await File.findOrFail(params.id)
|
const file = await File.findOrFail(params.id)
|
||||||
await file.delete()
|
await file.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'File successfully deleted!'
|
message: 'File successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import FormationStoreValidator from "App/Validators/formation/FormationStoreValidator";
|
import FormationStoreValidator from 'App/Validators/formation/FormationStoreValidator'
|
||||||
import FormationUpdateValidator from "App/Validators/formation/FormationUpdateValidator";
|
import FormationUpdateValidator from 'App/Validators/formation/FormationUpdateValidator'
|
||||||
import Formation from "App/Models/Formation";
|
import Formation from 'App/Models/Formation'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class FormationsController {
|
export default class FormationsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const formations = await Formation
|
const formations = await Formation
|
||||||
.query()
|
.query()
|
||||||
.orderBy('begin_date', 'desc')
|
.orderBy('begin_date', 'desc')
|
||||||
.preload('title')
|
.preload('title')
|
||||||
.preload('description')
|
.preload('description')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
formations: formations
|
formations,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(FormationStoreValidator)
|
const data = await request.validate(FormationStoreValidator)
|
||||||
const formation = await Formation.create(data)
|
const formation = await Formation.create(data)
|
||||||
|
|
||||||
@@ -25,44 +24,41 @@ export default class FormationsController {
|
|||||||
await formation.related('description').associate(await getTranslation(data.description))
|
await formation.related('description').associate(await getTranslation(data.description))
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
formation: formation
|
formation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
const formation = await Formation.findOrFail(params.id)
|
const formation = await Formation.findOrFail(params.id)
|
||||||
formation.load('title')
|
formation.load('title')
|
||||||
formation.load('description')
|
formation.load('description')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
formation
|
formation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const data = await request.validate(FormationUpdateValidator)
|
const data = await request.validate(FormationUpdateValidator)
|
||||||
const formation = await Formation.findOrFail(params.id)
|
const formation = await Formation.findOrFail(params.id)
|
||||||
|
|
||||||
if (data.title) {
|
if (data.title)
|
||||||
await formation.related('title').associate(await getTranslation(data.title))
|
await formation.related('title').associate(await getTranslation(data.title))
|
||||||
}
|
|
||||||
|
|
||||||
if (data.description) {
|
if (data.description)
|
||||||
await formation.related('description').associate(await getTranslation(data.description))
|
await formation.related('description').associate(await getTranslation(data.description))
|
||||||
}
|
|
||||||
|
|
||||||
await formation.merge(data).save()
|
await formation.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
formation
|
formation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const formation = await Formation.findOrFail(params.id)
|
const formation = await Formation.findOrFail(params.id)
|
||||||
await formation.delete()
|
await formation.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Formation successfully deleted!'
|
message: 'Formation successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,33 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import FormStoreValidator from "App/Validators/form/FormStoreValidator";
|
import FormStoreValidator from 'App/Validators/form/FormStoreValidator'
|
||||||
import Form from "App/Models/Form";
|
import Form from 'App/Models/Form'
|
||||||
|
|
||||||
export default class FormsController {
|
export default class FormsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
forms: Form.query().orderBy('created_at', 'asc')
|
forms: Form.query().orderBy('created_at', 'asc'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(FormStoreValidator)
|
const data = await request.validate(FormStoreValidator)
|
||||||
//todo send confirmation email + email to me with FormConfirmation
|
// todo send confirmation email + email to me with FormConfirmation
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
form: await Form.create(data)
|
form: await Form.create(data),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
form: await Form.findOrFail(params.id)
|
form: await Form.findOrFail(params.id),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const form = await Form.findOrFail(params.id)
|
const form = await Form.findOrFail(params.id)
|
||||||
await form.delete()
|
await form.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Form successfully deleted!'
|
message: 'Form successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Information from "App/Models/Information";
|
import Information from 'App/Models/Information'
|
||||||
import InformationUpdateValidator from "App/Validators/information/InformationUpdateValidator";
|
import InformationUpdateValidator from 'App/Validators/information/InformationUpdateValidator'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class InformationsController {
|
export default class InformationsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
informations: await Information
|
informations: await Information
|
||||||
.query()
|
.query()
|
||||||
.preload('translation')
|
.preload('translation')
|
||||||
.first()
|
.first(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ response, request }: HttpContextContract) {
|
public async update({ response, request }: HttpContextContract) {
|
||||||
const information = await Information.firstOrFail()
|
const information = await Information.firstOrFail()
|
||||||
const data = await request.validate(InformationUpdateValidator)
|
const data = await request.validate(InformationUpdateValidator)
|
||||||
|
|
||||||
@@ -26,8 +25,7 @@ export default class InformationsController {
|
|||||||
await information.merge(data).save()
|
await information.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
information
|
information,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,31 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Location from "App/Models/Location";
|
import Location from 'App/Models/Location'
|
||||||
import LocationValidator from "App/Validators/location/LocationValidator";
|
import LocationValidator from 'App/Validators/location/LocationValidator'
|
||||||
|
|
||||||
export default class LocationsController {
|
export default class LocationsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const location = await Location.query().orderBy('since', 'desc').first()
|
const location = await Location.query().orderBy('since', 'desc').first()
|
||||||
if (location) {
|
if (location) {
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
location: {
|
location: {
|
||||||
place: location.place,
|
place: location.place,
|
||||||
left: location.left,
|
left: location.left,
|
||||||
since: location.since
|
since: location.since,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
location: 'Location is unknown...'
|
location: 'Location is unknown...',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(LocationValidator)
|
const data = await request.validate(LocationValidator)
|
||||||
const location = await Location.create(data)
|
const location = await Location.create(data)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
location
|
location,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Maintenance from "App/Models/Maintenance";
|
import Maintenance from 'App/Models/Maintenance'
|
||||||
import MaintenanceUpdateValidator from "App/Validators/maintenance/MaintenanceUpdateValidator";
|
import MaintenanceUpdateValidator from 'App/Validators/maintenance/MaintenanceUpdateValidator'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class MaintenancesController {
|
export default class MaintenancesController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const maintenance = await Maintenance
|
const maintenance = await Maintenance
|
||||||
.query()
|
.query()
|
||||||
.orderBy('created_at', 'desc')
|
.orderBy('created_at', 'desc')
|
||||||
.preload('reason')
|
.preload('reason')
|
||||||
.first()
|
.first()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
maintenance: maintenance
|
maintenance,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const data = await request.validate(MaintenanceUpdateValidator)
|
const data = await request.validate(MaintenanceUpdateValidator)
|
||||||
const maintenance = await Maintenance.findOrFail(params.id)
|
const maintenance = await Maintenance.findOrFail(params.id)
|
||||||
|
|
||||||
if (data.reason) {
|
if (data.reason)
|
||||||
await maintenance.related('reason').associate(await getTranslation(data.reason))
|
await maintenance.related('reason').associate(await getTranslation(data.reason))
|
||||||
}
|
|
||||||
|
|
||||||
await maintenance.merge(data).save()
|
await maintenance.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
maintenance
|
maintenance,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,44 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import PostColor from "App/Models/PostColor";
|
import PostColor from 'App/Models/PostColor'
|
||||||
import PostColorStoreValidator from "App/Validators/postColor/PostColorStoreValidator";
|
import PostColorStoreValidator from 'App/Validators/postColor/PostColorStoreValidator'
|
||||||
import PostColorUpdateValidator from "App/Validators/postColor/PostColorUpdateValidator";
|
import PostColorUpdateValidator from 'App/Validators/postColor/PostColorUpdateValidator'
|
||||||
|
|
||||||
export default class PostColorsController {
|
export default class PostColorsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post_colors: await PostColor.all()
|
post_colors: await PostColor.all(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(PostColorStoreValidator)
|
const data = await request.validate(PostColorStoreValidator)
|
||||||
const postColor = await PostColor.create(data)
|
const postColor = await PostColor.create(data)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post_color: postColor
|
post_color: postColor,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
const postColor = await PostColor.findOrFail(params.id)
|
const postColor = await PostColor.findOrFail(params.id)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post_color: postColor
|
post_color: postColor,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const data = await request.validate(PostColorUpdateValidator)
|
const data = await request.validate(PostColorUpdateValidator)
|
||||||
const postColor = await PostColor.findOrFail(params.id)
|
const postColor = await PostColor.findOrFail(params.id)
|
||||||
await postColor.merge(data).save()
|
await postColor.merge(data).save()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post_color: postColor
|
post_color: postColor,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const postColor = await PostColor.findOrFail(params.id)
|
const postColor = await PostColor.findOrFail(params.id)
|
||||||
await postColor.delete()
|
await postColor.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'PostColor successfully deleted!'
|
message: 'PostColor successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import Post from "App/Models/Post";
|
import Post from 'App/Models/Post'
|
||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import PostUpdateValidator from "App/Validators/post/PostUpdateValidator";
|
import PostUpdateValidator from 'App/Validators/post/PostUpdateValidator'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
import PostStoreValidator from "App/Validators/post/PostStoreValidator";
|
import PostStoreValidator from 'App/Validators/post/PostStoreValidator'
|
||||||
import PostColor from "App/Models/PostColor";
|
import PostColor from 'App/Models/PostColor'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class PostsController {
|
export default class PostsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
posts: await Post.query()
|
posts: await Post.query()
|
||||||
.orderBy('id', 'desc')
|
.orderBy('id', 'desc')
|
||||||
@@ -19,11 +18,11 @@ export default class PostsController {
|
|||||||
.preload('color')
|
.preload('color')
|
||||||
.preload('content')
|
.preload('content')
|
||||||
.preload('title')
|
.preload('title')
|
||||||
.preload('description')
|
.preload('description'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(PostStoreValidator)
|
const data = await request.validate(PostStoreValidator)
|
||||||
const post = await Post.create(data)
|
const post = await Post.create(data)
|
||||||
|
|
||||||
@@ -40,11 +39,11 @@ export default class PostsController {
|
|||||||
await post.related('tags').sync(data.tags!)
|
await post.related('tags').sync(data.tags!)
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
const post = await Post.findOrFail(params.id)
|
const post = await Post.findOrFail(params.id)
|
||||||
await post.load('cover')
|
await post.load('cover')
|
||||||
await post.load('title')
|
await post.load('title')
|
||||||
@@ -55,16 +54,16 @@ export default class PostsController {
|
|||||||
tags.preload('label')
|
tags.preload('label')
|
||||||
})
|
})
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async get ({ params, response }: HttpContextContract) {
|
public async get({ params, response }: HttpContextContract) {
|
||||||
const post = await Post.firstOrCreate({
|
const post = await Post.firstOrCreate({
|
||||||
slug: params.slug
|
slug: params.slug,
|
||||||
}, {
|
}, {
|
||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
likes: 0
|
likes: 0,
|
||||||
})
|
})
|
||||||
await post.load('tags', (tags) => {
|
await post.load('tags', (tags) => {
|
||||||
tags.preload('label')
|
tags.preload('label')
|
||||||
@@ -75,11 +74,11 @@ export default class PostsController {
|
|||||||
await post.load('content')
|
await post.load('content')
|
||||||
await post.load('color')
|
await post.load('color')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const post = await Post.findOrFail(params.id)
|
const post = await Post.findOrFail(params.id)
|
||||||
const data = await request.validate(PostUpdateValidator)
|
const data = await request.validate(PostUpdateValidator)
|
||||||
|
|
||||||
@@ -97,43 +96,42 @@ export default class PostsController {
|
|||||||
if (color) await post.related('color').associate(color)
|
if (color) await post.related('color').associate(color)
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const post = await Post.findOrFail(params.id)
|
const post = await Post.findOrFail(params.id)
|
||||||
await post.delete()
|
await post.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Post successfully deleted!'
|
message: 'Post successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async like ({ params, response }: HttpContextContract) {
|
public async like({ params, response }: HttpContextContract) {
|
||||||
const post = await Post.firstOrCreate({
|
const post = await Post.firstOrCreate({
|
||||||
slug: params.slug
|
slug: params.slug,
|
||||||
}, {
|
}, {
|
||||||
slug: params.slug,
|
slug: params.slug,
|
||||||
likes: 0
|
likes: 0,
|
||||||
})
|
})
|
||||||
const getLikes = post.likes
|
const getLikes = post.likes
|
||||||
await post.merge({
|
await post.merge({
|
||||||
likes: getLikes + 1
|
likes: getLikes + 1,
|
||||||
}).save()
|
}).save()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async unlike ({ params, response }: HttpContextContract) {
|
public async unlike({ params, response }: HttpContextContract) {
|
||||||
const post = await Post.findByOrFail('slug', params.slug)
|
const post = await Post.findByOrFail('slug', params.slug)
|
||||||
const getLikes = post.likes
|
const getLikes = post.likes
|
||||||
await post.merge({
|
await post.merge({
|
||||||
likes: getLikes - 1
|
likes: getLikes - 1,
|
||||||
}).save()
|
}).save()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
post
|
post,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,46 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class ProfileController {
|
export default class ProfileController {
|
||||||
|
public me({ response }: HttpContextContract) {
|
||||||
public me ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
pronouns: "Arthur",
|
pronouns: 'Arthur',
|
||||||
home: ["Paris", "France"],
|
home: ['Paris', 'France'],
|
||||||
passions: [
|
passions: [
|
||||||
"Dev",
|
'Dev',
|
||||||
"DevOps",
|
'DevOps',
|
||||||
"New technologies",
|
'New technologies',
|
||||||
"Gaming",
|
'Gaming',
|
||||||
"Cloud"
|
'Cloud',
|
||||||
],
|
],
|
||||||
code: [
|
code: [
|
||||||
"Javascript",
|
'Javascript',
|
||||||
"Typescript",
|
'Typescript',
|
||||||
"HTML",
|
'HTML',
|
||||||
"CSS",
|
'CSS',
|
||||||
"GoLang",
|
'GoLang',
|
||||||
"Java"
|
'Java',
|
||||||
],
|
],
|
||||||
ask_me_about: [
|
ask_me_about: [
|
||||||
"Web dev",
|
'Web dev',
|
||||||
"Tech",
|
'Tech',
|
||||||
"Consulting",
|
'Consulting',
|
||||||
"Cloud computing",
|
'Cloud computing',
|
||||||
"DevOps",
|
'DevOps',
|
||||||
"Software dev"
|
'Software dev',
|
||||||
],
|
],
|
||||||
technologies: {
|
technologies: {
|
||||||
web_app: ["VueJs", "NuxtJs", "Sass", "TailwindCss", "WindiCss"],
|
web_app: ['VueJs', 'NuxtJs', 'Sass', 'TailwindCss', 'WindiCss'],
|
||||||
desktop_app: ["ElectronJs"],
|
desktop_app: ['ElectronJs'],
|
||||||
mobile_app: ["React Native", "Vue Native"],
|
mobile_app: ['React Native', 'Vue Native'],
|
||||||
back_end: {
|
back_end: {
|
||||||
typescript: ["AdonisJs"],
|
typescript: ['AdonisJs'],
|
||||||
java: ["Spring"]
|
java: ['Spring'],
|
||||||
},
|
},
|
||||||
databases: ["MongoDB", "MariaDB", "Redis"],
|
databases: ['MongoDB', 'MariaDB', 'Redis'],
|
||||||
messaging: ["RabbitMQ"],
|
messaging: ['RabbitMQ'],
|
||||||
other: ["Docker", "Git"],
|
other: ['Docker', 'Git'],
|
||||||
architecture: ["microservices", "event-driven", "design system pattern"],
|
architecture: ['microservices', 'event-driven', 'design system pattern'],
|
||||||
operating_systems: ['MacOS', "Linux"]
|
operating_systems: ['MacOS', 'Linux'],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Project from "App/Models/Project";
|
import Project from 'App/Models/Project'
|
||||||
import ProjectStoreValidator from "App/Validators/project/ProjectStoreValidator";
|
import ProjectStoreValidator from 'App/Validators/project/ProjectStoreValidator'
|
||||||
import ProjectUpdateValidator from "App/Validators/project/ProjectUpdateValidator";
|
import ProjectUpdateValidator from 'App/Validators/project/ProjectUpdateValidator'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class ProjectsController {
|
export default class ProjectsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
projects: await Project.query()
|
projects: await Project.query()
|
||||||
.orderBy('id', 'asc')
|
.orderBy('id', 'asc')
|
||||||
@@ -15,11 +14,11 @@ export default class ProjectsController {
|
|||||||
.preload('description')
|
.preload('description')
|
||||||
.preload('tags', (tags) => {
|
.preload('tags', (tags) => {
|
||||||
tags.preload('label')
|
tags.preload('label')
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(ProjectStoreValidator)
|
const data = await request.validate(ProjectStoreValidator)
|
||||||
const project = await Project.create(data)
|
const project = await Project.create(data)
|
||||||
const cover = await File.findByOrFail('label', data.cover)
|
const cover = await File.findByOrFail('label', data.cover)
|
||||||
@@ -28,11 +27,11 @@ export default class ProjectsController {
|
|||||||
await project.related('description').associate(await getTranslation(data.description))
|
await project.related('description').associate(await getTranslation(data.description))
|
||||||
await project.related('tags').sync(data.tags!)
|
await project.related('tags').sync(data.tags!)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
project
|
project,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
const project = await Project.findOrFail(params.id)
|
const project = await Project.findOrFail(params.id)
|
||||||
await project.load('cover')
|
await project.load('cover')
|
||||||
await project.load('description')
|
await project.load('description')
|
||||||
@@ -40,11 +39,11 @@ export default class ProjectsController {
|
|||||||
tags.preload('label')
|
tags.preload('label')
|
||||||
})
|
})
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
project
|
project,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const project = await Project.findOrFail(params.id)
|
const project = await Project.findOrFail(params.id)
|
||||||
const data = await request.validate(ProjectUpdateValidator)
|
const data = await request.validate(ProjectUpdateValidator)
|
||||||
const cover = await File.findBy('label', data.cover)
|
const cover = await File.findBy('label', data.cover)
|
||||||
@@ -56,16 +55,15 @@ export default class ProjectsController {
|
|||||||
|
|
||||||
await project.related('tags').sync(data.tags!)
|
await project.related('tags').sync(data.tags!)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
project
|
project,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const project = await Project.findOrFail(params.id)
|
const project = await Project.findOrFail(params.id)
|
||||||
await project.delete()
|
await project.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Project successfully deleted!'
|
message: 'Project successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
import Skill from "App/Models/Skill";
|
import Skill from 'App/Models/Skill'
|
||||||
import SkillStoreValidator from "App/Validators/skill/SkillStoreValidator";
|
import SkillStoreValidator from 'App/Validators/skill/SkillStoreValidator'
|
||||||
import SkillUpdateValidator from "App/Validators/skill/SkillUpdateValidator";
|
import SkillUpdateValidator from 'App/Validators/skill/SkillUpdateValidator'
|
||||||
|
|
||||||
export default class SkillsController {
|
export default class SkillsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const skills = await Skill
|
const skills = await Skill
|
||||||
.query()
|
.query()
|
||||||
.preload('file')
|
.preload('file')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
skills: skills
|
skills,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(SkillStoreValidator)
|
const data = await request.validate(SkillStoreValidator)
|
||||||
const skill = await Skill.create(data)
|
const skill = await Skill.create(data)
|
||||||
|
|
||||||
@@ -23,19 +22,19 @@ export default class SkillsController {
|
|||||||
if (cover) await skill.related('file').associate(cover)
|
if (cover) await skill.related('file').associate(cover)
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
skill: skill
|
skill,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
const skill = await Skill.findOrFail(params.id)
|
const skill = await Skill.findOrFail(params.id)
|
||||||
skill.load('file')
|
skill.load('file')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
skill
|
skill,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const data = await request.validate(SkillUpdateValidator)
|
const data = await request.validate(SkillUpdateValidator)
|
||||||
const skill = await Skill.findOrFail(params.id)
|
const skill = await Skill.findOrFail(params.id)
|
||||||
|
|
||||||
@@ -44,16 +43,15 @@ export default class SkillsController {
|
|||||||
await skill.merge(data).save()
|
await skill.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
skill
|
skill,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const skill = await Skill.findOrFail(params.id)
|
const skill = await Skill.findOrFail(params.id)
|
||||||
await skill.delete()
|
await skill.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Skill successfully deleted!'
|
message: 'Skill successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,31 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Redis from "@ioc:Adonis/Addons/Redis";
|
import Redis from '@ioc:Adonis/Addons/Redis'
|
||||||
import StateSleepingValidator from "App/Validators/states/StateSleepingValidator";
|
import StateSleepingValidator from 'App/Validators/states/StateSleepingValidator'
|
||||||
|
|
||||||
export default class StatesController {
|
export default class StatesController {
|
||||||
|
|
||||||
// Listening Music
|
// Listening Music
|
||||||
|
|
||||||
public async index ({ response }: HttpContextContract) {
|
public async index({ response }: HttpContextContract) {
|
||||||
const sleeping = this.formatValue(await Redis.get('states:sleeping'))
|
const sleeping = this.formatValue(await Redis.get('states:sleeping'))
|
||||||
const developing = this.formatValue(await Redis.get('states:developing'))
|
const developing = this.formatValue(await Redis.get('states:developing'))
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
sleeping,
|
sleeping,
|
||||||
developing,
|
developing,
|
||||||
listening_music: "Soon"
|
listening_music: 'Soon',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setSleeping ({ request, response }: HttpContextContract) {
|
public async setSleeping({ request, response }: HttpContextContract) {
|
||||||
const { value } = await request.validate(StateSleepingValidator)
|
const { value } = await request.validate(StateSleepingValidator)
|
||||||
await Redis.set('states:sleeping', String(value))
|
await Redis.set('states:sleeping', String(value))
|
||||||
await Redis.set('states:developing', String(!value))
|
await Redis.set('states:developing', String(!value))
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'State was successfully set!',
|
message: 'State was successfully set!',
|
||||||
value: this.formatValue(String(value))
|
value: this.formatValue(String(value)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public formatValue(value: string | null): string {
|
public formatValue(value: string | null): string {
|
||||||
return value === 'true' ? 'Yes' : 'No'
|
return value === 'true' ? 'Yes' : 'No'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import CommandsRun from "App/Models/CommandsRun";
|
import CommandsRun from 'App/Models/CommandsRun'
|
||||||
import BuildsRun from "App/Models/BuildsRun";
|
import BuildsRun from 'App/Models/BuildsRun'
|
||||||
import {
|
import {
|
||||||
fetchDailyStatistics,
|
fetchDailyStatistics,
|
||||||
fetchMonthlyStatistics,
|
fetchMonthlyStatistics,
|
||||||
fetchStatistics,
|
fetchStatistics,
|
||||||
fetchWeeklyStatistics,
|
fetchWeeklyStatistics,
|
||||||
NOW
|
NOW,
|
||||||
} from "App/Utils/StatsUtils";
|
} from 'App/Utils/StatsUtils'
|
||||||
|
|
||||||
export default class StatsController {
|
export default class StatsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const daily = await fetchDailyStatistics()
|
const daily = await fetchDailyStatistics()
|
||||||
const weekly = await fetchWeeklyStatistics()
|
const weekly = await fetchWeeklyStatistics()
|
||||||
const monthly = await fetchMonthlyStatistics()
|
const monthly = await fetchMonthlyStatistics()
|
||||||
@@ -25,46 +24,45 @@ export default class StatsController {
|
|||||||
development_time: total.development_time,
|
development_time: total.development_time,
|
||||||
commands_run: total.commands_ran,
|
commands_run: total.commands_ran,
|
||||||
builds_run: total.builds_ran,
|
builds_run: total.builds_ran,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async incrementCommandCount({ response }: HttpContextContract) {
|
public async incrementCommandCount({ response }: HttpContextContract) {
|
||||||
const current_commands = await CommandsRun.firstOrCreate(
|
const current_commands = await CommandsRun.firstOrCreate(
|
||||||
{
|
{
|
||||||
date: NOW
|
date: NOW,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: NOW,
|
date: NOW,
|
||||||
commands: 0
|
commands: 0,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
current_commands.commands++
|
current_commands.commands++
|
||||||
await current_commands.save()
|
await current_commands.save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Commands Count successfully incremented!'
|
message: 'Commands Count successfully incremented!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async incrementBuildCount({ response }: HttpContextContract) {
|
public async incrementBuildCount({ response }: HttpContextContract) {
|
||||||
const current_builds = await BuildsRun.firstOrCreate(
|
const current_builds = await BuildsRun.firstOrCreate(
|
||||||
{
|
{
|
||||||
date: NOW
|
date: NOW,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: NOW,
|
date: NOW,
|
||||||
builds: 0
|
builds: 0,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
current_builds.builds++
|
current_builds.builds++
|
||||||
await current_builds.save()
|
await current_builds.save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Builds Count successfully incremented!'
|
message: 'Builds Count successfully incremented!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,28 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Subscriber from "App/Models/Subscriber";
|
import Subscriber from 'App/Models/Subscriber'
|
||||||
import SubscriberStoreValidator from "App/Validators/subscriber/SubscriberStoreValidator";
|
import SubscriberStoreValidator from 'App/Validators/subscriber/SubscriberStoreValidator'
|
||||||
|
|
||||||
export default class SubscribersController {
|
export default class SubscribersController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const subscribers = await Subscriber.query()
|
const subscribers = await Subscriber.query()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
count: subscribers.length,
|
count: subscribers.length,
|
||||||
subscribers: subscribers
|
subscribers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(SubscriberStoreValidator)
|
const data = await request.validate(SubscriberStoreValidator)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
subscriber: await Subscriber.create(data)
|
subscriber: await Subscriber.create(data),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ params, response }: HttpContextContract) {
|
public async destroy({ params, response }: HttpContextContract) {
|
||||||
const subscriber = await Subscriber.findOrFail(params.id)
|
const subscriber = await Subscriber.findOrFail(params.id)
|
||||||
await subscriber.delete()
|
await subscriber.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Subscriber successfully deleted!'
|
message: 'Subscriber successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +1,55 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import TagStoreValidator from "App/Validators/tag/TagStoreValidator";
|
import TagStoreValidator from 'App/Validators/tag/TagStoreValidator'
|
||||||
import TagUpdateValidator from "App/Validators/tag/TagUpdateValidator";
|
import TagUpdateValidator from 'App/Validators/tag/TagUpdateValidator'
|
||||||
import Tag from "App/Models/Tag";
|
import Tag from 'App/Models/Tag'
|
||||||
import {getTranslation} from "App/Utils/TranslationsUtils";
|
import { getTranslation } from 'App/Utils/TranslationsUtils'
|
||||||
|
|
||||||
export default class TagsController {
|
export default class TagsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
const tags = await Tag
|
const tags = await Tag
|
||||||
.query()
|
.query()
|
||||||
.preload('label')
|
.preload('label')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
tags: tags
|
tags,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(TagStoreValidator)
|
const data = await request.validate(TagStoreValidator)
|
||||||
const tag = await Tag.create({})
|
const tag = await Tag.create({})
|
||||||
|
|
||||||
await tag.related('label').associate(await getTranslation(data.label))
|
await tag.related('label').associate(await getTranslation(data.label))
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
tag: tag
|
tag,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
const tag = await Tag.findOrFail(params.id)
|
const tag = await Tag.findOrFail(params.id)
|
||||||
tag.load('label')
|
tag.load('label')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
tag
|
tag,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const data = await request.validate(TagUpdateValidator)
|
const data = await request.validate(TagUpdateValidator)
|
||||||
const tag = await Tag.findOrFail(params.id)
|
const tag = await Tag.findOrFail(params.id)
|
||||||
|
|
||||||
if (data.label) {
|
if (data.label)
|
||||||
await tag.related('label').associate(await getTranslation(data.label))
|
await tag.related('label').associate(await getTranslation(data.label))
|
||||||
}
|
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
tag
|
tag,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const tag = await Tag.findOrFail(params.id)
|
const tag = await Tag.findOrFail(params.id)
|
||||||
await tag.delete()
|
await tag.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Tag successfully deleted!'
|
message: 'Tag successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,43 @@
|
|||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
import TranslationStoreValidator from "App/Validators/translation/TranslationStoreValidator";
|
import TranslationStoreValidator from 'App/Validators/translation/TranslationStoreValidator'
|
||||||
import TranslationUpdateValidator from "App/Validators/translation/TranslationUpdateValidator";
|
import TranslationUpdateValidator from 'App/Validators/translation/TranslationUpdateValidator'
|
||||||
|
|
||||||
export default class TranslationsController {
|
export default class TranslationsController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
translations: await Translation.query().orderBy('id', 'asc')
|
translations: await Translation.query().orderBy('id', 'asc'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(TranslationStoreValidator)
|
const data = await request.validate(TranslationStoreValidator)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
translation: await Translation.create(data)
|
translation: await Translation.create(data),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
translation: await Translation.findOrFail(params.id)
|
translation: await Translation.findOrFail(params.id),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const translation = await Translation.findOrFail(params.id)
|
const translation = await Translation.findOrFail(params.id)
|
||||||
const data = await request.validate(TranslationUpdateValidator)
|
const data = await request.validate(TranslationUpdateValidator)
|
||||||
await translation.merge(data).save()
|
await translation.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
translation
|
translation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params }: HttpContextContract) {
|
public async destroy({ response, params }: HttpContextContract) {
|
||||||
const translation = await Translation.findOrFail(params.id)
|
const translation = await Translation.findOrFail(params.id)
|
||||||
await translation.delete()
|
await translation.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'Translation successfully deleted!'
|
message: 'Translation successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,48 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import User from "App/Models/User";
|
import User from 'App/Models/User'
|
||||||
import UserStoreValidator from "App/Validators/user/UserStoreValidator";
|
import UserStoreValidator from 'App/Validators/user/UserStoreValidator'
|
||||||
import UserUpdateValidator from "App/Validators/user/UserUpdateValidator";
|
import UserUpdateValidator from 'App/Validators/user/UserUpdateValidator'
|
||||||
|
|
||||||
export default class UsersController {
|
export default class UsersController {
|
||||||
|
public async index({ response }: HttpContextContract) {
|
||||||
public async index ({ response }: HttpContextContract) {
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
users: await User.all()
|
users: await User.all(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async store ({ request, response }: HttpContextContract) {
|
public async store({ request, response }: HttpContextContract) {
|
||||||
const data = await request.validate(UserStoreValidator)
|
const data = await request.validate(UserStoreValidator)
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
user: await User.create(data)
|
user: await User.create(data),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async show ({ params, response }: HttpContextContract) {
|
public async show({ params, response }: HttpContextContract) {
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
user: await User.findOrFail(params.id)
|
user: await User.findOrFail(params.id),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async update ({ request, params, response }: HttpContextContract) {
|
public async update({ request, params, response }: HttpContextContract) {
|
||||||
const user = await User.findOrFail(params.id)
|
const user = await User.findOrFail(params.id)
|
||||||
const data = await request.validate(UserUpdateValidator)
|
const data = await request.validate(UserUpdateValidator)
|
||||||
await user.merge(data).save()
|
await user.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
user
|
user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async destroy ({ response, params, auth }: HttpContextContract) {
|
public async destroy({ response, params, auth }: HttpContextContract) {
|
||||||
const user = await User.findOrFail(params.id)
|
const user = await User.findOrFail(params.id)
|
||||||
const admin = await User.findBy('email', 'arthurdanjou@outlook.fr')
|
const admin = await User.findBy('email', 'arthurdanjou@outlook.fr')
|
||||||
|
|
||||||
if (auth.user?.id != admin?.id) {
|
if (auth.user?.id !== admin?.id)
|
||||||
return response.unauthorized()
|
return response.unauthorized()
|
||||||
}
|
|
||||||
|
|
||||||
await user.delete()
|
await user.delete()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'User successfully deleted!'
|
message: 'User successfully deleted!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import Logger from '@ioc:Adonis/Core/Logger'
|
|||||||
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'
|
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'
|
||||||
|
|
||||||
export default class ExceptionHandler extends HttpExceptionHandler {
|
export default class ExceptionHandler extends HttpExceptionHandler {
|
||||||
constructor () {
|
constructor() {
|
||||||
super(Logger)
|
super(Logger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { BaseMailer, MessageContract } from '@ioc:Adonis/Addons/Mail'
|
import { BaseMailer, MessageContract } from '@ioc:Adonis/Addons/Mail'
|
||||||
|
|
||||||
export default class FormConfirmation extends BaseMailer {
|
export default class FormConfirmation extends BaseMailer {
|
||||||
|
constructor(private name: string, private email: string) {
|
||||||
constructor (private name: string, private email: string) {
|
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public html = mjml(View.render('emails/confirmation_form', {
|
/* public html = mjml(View.render('emails/confirmation_form', {
|
||||||
name: this.name
|
name: this.name
|
||||||
})).html*/
|
})).html */
|
||||||
|
|
||||||
public prepare(message: MessageContract) {
|
public prepare(message: MessageContract) {
|
||||||
message
|
message
|
||||||
@@ -18,7 +17,7 @@ export default class FormConfirmation extends BaseMailer {
|
|||||||
.subject('Thank you for contacting !')
|
.subject('Thank you for contacting !')
|
||||||
.htmlView('emails/confirmation_form', {
|
.htmlView('emails/confirmation_form', {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
url: 'https://arthurdanjou.fr'
|
url: 'https://arthurdanjou.fr',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import {AuthenticationException} from '@adonisjs/auth/build/standalone'
|
import { AuthenticationException } from '@adonisjs/auth/build/standalone'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auth middleware is meant to restrict un-authenticated access to a given route
|
* Auth middleware is meant to restrict un-authenticated access to a given route
|
||||||
@@ -22,7 +22,7 @@ export default class AuthMiddleware {
|
|||||||
* of the mentioned guards and that guard will be used by the rest of the code
|
* of the mentioned guards and that guard will be used by the rest of the code
|
||||||
* during the current request.
|
* during the current request.
|
||||||
*/
|
*/
|
||||||
protected async authenticate (auth: HttpContextContract['auth'], guards: any[]) {
|
protected async authenticate(auth: HttpContextContract['auth'], guards: any[]) {
|
||||||
/**
|
/**
|
||||||
* Hold reference to the guard last attempted within the for loop. We pass
|
* Hold reference to the guard last attempted within the for loop. We pass
|
||||||
* the reference of the guard to the "AuthenticationException", so that
|
* the reference of the guard to the "AuthenticationException", so that
|
||||||
@@ -31,7 +31,7 @@ export default class AuthMiddleware {
|
|||||||
*/
|
*/
|
||||||
let guardLastAttempted: string | undefined
|
let guardLastAttempted: string | undefined
|
||||||
|
|
||||||
for (let guard of guards) {
|
for (const guard of guards) {
|
||||||
guardLastAttempted = guard
|
guardLastAttempted = guard
|
||||||
if (await auth.use(guard).check()) {
|
if (await auth.use(guard).check()) {
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +58,7 @@ export default class AuthMiddleware {
|
|||||||
/**
|
/**
|
||||||
* Handle request
|
* Handle request
|
||||||
*/
|
*/
|
||||||
public async handle ({ auth }: HttpContextContract, next: () => Promise<void>, customGuards: string[]) {
|
public async handle({ auth }: HttpContextContract, next: () => Promise<void>, customGuards: string[]) {
|
||||||
/**
|
/**
|
||||||
* Uses the user defined guards or the default guard mentioned in
|
* Uses the user defined guards or the default guard mentioned in
|
||||||
* the config file
|
* the config file
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default class SilentAuthMiddleware {
|
|||||||
/**
|
/**
|
||||||
* Handle request
|
* Handle request
|
||||||
*/
|
*/
|
||||||
public async handle ({ auth }: HttpContextContract, next: () => Promise<void>) {
|
public async handle({ auth }: HttpContextContract, next: () => Promise<void>) {
|
||||||
/**
|
/**
|
||||||
* Check if user is logged-in or not. If yes, then `ctx.auth.user` will be
|
* Check if user is logged-in or not. If yes, then `ctx.auth.user` will be
|
||||||
* set to the instance of the currently logged in user.
|
* set to the instance of the currently logged in user.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {DateTime} from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export default class Announce extends BaseModel {
|
export default class Announce extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
@@ -14,7 +14,7 @@ export default class Announce extends BaseModel {
|
|||||||
public hoverColor: string
|
public hoverColor: string
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'messageId'
|
foreignKey: 'messageId',
|
||||||
})
|
})
|
||||||
public message: BelongsTo<typeof Translation>
|
public message: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ export default class Announce extends BaseModel {
|
|||||||
public messageId: number
|
public messageId: number
|
||||||
|
|
||||||
@belongsTo(() => File, {
|
@belongsTo(() => File, {
|
||||||
foreignKey: 'coverId'
|
foreignKey: 'coverId',
|
||||||
})
|
})
|
||||||
public cover: BelongsTo<typeof File>
|
public cover: BelongsTo<typeof File>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
export default class DevelopmentHour extends BaseModel {
|
export default class DevelopmentHour extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export default class Experience extends BaseModel {
|
export default class Experience extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
public id: number
|
public id: number
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'titleId'
|
foreignKey: 'titleId',
|
||||||
})
|
})
|
||||||
public title: BelongsTo<typeof Translation>
|
public title: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
export default class File extends BaseModel {
|
export default class File extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export default class Formation extends BaseModel {
|
export default class Formation extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
public id: number
|
public id: number
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'titleId'
|
foreignKey: 'titleId',
|
||||||
})
|
})
|
||||||
public title: BelongsTo<typeof Translation>
|
public title: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ export default class Formation extends BaseModel {
|
|||||||
public titleId: number
|
public titleId: number
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'descriptionId'
|
foreignKey: 'descriptionId',
|
||||||
})
|
})
|
||||||
public description: BelongsTo<typeof Translation>
|
public description: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {DateTime} from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export default class Information extends BaseModel {
|
export default class Information extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export default class Maintenance extends BaseModel {
|
export default class Maintenance extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
@@ -10,7 +10,7 @@ export default class Maintenance extends BaseModel {
|
|||||||
public active: boolean
|
public active: boolean
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'reasonId'
|
foreignKey: 'reasonId',
|
||||||
})
|
})
|
||||||
public reason: BelongsTo<typeof Translation>
|
public reason: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column, manyToMany, ManyToMany} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column, manyToMany, ManyToMany } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import Tag from "App/Models/Tag";
|
import Tag from 'App/Models/Tag'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
import PostColor from "App/Models/PostColor";
|
import PostColor from 'App/Models/PostColor'
|
||||||
|
|
||||||
export default class Post extends BaseModel {
|
export default class Post extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
@@ -19,7 +19,7 @@ export default class Post extends BaseModel {
|
|||||||
public likes: number
|
public likes: number
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'titleId'
|
foreignKey: 'titleId',
|
||||||
})
|
})
|
||||||
public title: BelongsTo<typeof Translation>
|
public title: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ export default class Post extends BaseModel {
|
|||||||
public titleId: number
|
public titleId: number
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'descriptionId'
|
foreignKey: 'descriptionId',
|
||||||
})
|
})
|
||||||
public description: BelongsTo<typeof Translation>
|
public description: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export default class Post extends BaseModel {
|
|||||||
public descriptionId: number
|
public descriptionId: number
|
||||||
|
|
||||||
@belongsTo(() => File, {
|
@belongsTo(() => File, {
|
||||||
foreignKey: 'coverId'
|
foreignKey: 'coverId',
|
||||||
})
|
})
|
||||||
public cover: BelongsTo<typeof File>
|
public cover: BelongsTo<typeof File>
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ export default class Post extends BaseModel {
|
|||||||
public coverId: number
|
public coverId: number
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'contentId'
|
foreignKey: 'contentId',
|
||||||
})
|
})
|
||||||
public content: BelongsTo<typeof Translation>
|
public content: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export default class Post extends BaseModel {
|
|||||||
public contentId: number
|
public contentId: number
|
||||||
|
|
||||||
@belongsTo(() => PostColor, {
|
@belongsTo(() => PostColor, {
|
||||||
foreignKey: 'colorId'
|
foreignKey: 'colorId',
|
||||||
})
|
})
|
||||||
public color: BelongsTo<typeof PostColor>
|
public color: BelongsTo<typeof PostColor>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {DateTime} from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column, ManyToMany, manyToMany} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column, ManyToMany, manyToMany } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
import Tag from "App/Models/Tag";
|
import Tag from 'App/Models/Tag'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export default class Project extends BaseModel {
|
export default class Project extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
@@ -12,7 +12,7 @@ export default class Project extends BaseModel {
|
|||||||
public name: string
|
public name: string
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'descriptionId'
|
foreignKey: 'descriptionId',
|
||||||
})
|
})
|
||||||
public description: BelongsTo<typeof Translation>
|
public description: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ export default class Project extends BaseModel {
|
|||||||
public url: string
|
public url: string
|
||||||
|
|
||||||
@belongsTo(() => File, {
|
@belongsTo(() => File, {
|
||||||
foreignKey: 'coverId'
|
foreignKey: 'coverId',
|
||||||
})
|
})
|
||||||
public cover: BelongsTo<typeof File>
|
public cover: BelongsTo<typeof File>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import File from "App/Models/File";
|
import File from 'App/Models/File'
|
||||||
|
|
||||||
export default class Skill extends BaseModel {
|
export default class Skill extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, BelongsTo, belongsTo, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export default class Tag extends BaseModel {
|
export default class Tag extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
public id: number
|
public id: number
|
||||||
|
|
||||||
@belongsTo(() => Translation, {
|
@belongsTo(() => Translation, {
|
||||||
foreignKey: 'labelId'
|
foreignKey: 'labelId',
|
||||||
})
|
})
|
||||||
public label: BelongsTo<typeof Translation>
|
public label: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {DateTime} from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
export default class Translation extends BaseModel {
|
export default class Translation extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {DateTime} from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import Hash from '@ioc:Adonis/Core/Hash'
|
import Hash from '@ioc:Adonis/Core/Hash'
|
||||||
import {BaseModel, beforeSave, column} from '@ioc:Adonis/Lucid/Orm'
|
import { BaseModel, beforeSave, column } from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
export default class User extends BaseModel {
|
export default class User extends BaseModel {
|
||||||
@column({isPrimary: true})
|
@column({ isPrimary: true })
|
||||||
public id: number
|
public id: number
|
||||||
|
|
||||||
@column()
|
@column()
|
||||||
@@ -24,16 +24,15 @@ export default class User extends BaseModel {
|
|||||||
@column()
|
@column()
|
||||||
public rememberMeToken?: string
|
public rememberMeToken?: string
|
||||||
|
|
||||||
@column.dateTime({autoCreate: true})
|
@column.dateTime({ autoCreate: true })
|
||||||
public createdAt: DateTime
|
public createdAt: DateTime
|
||||||
|
|
||||||
@column.dateTime({autoCreate: true, autoUpdate: true})
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||||
public updatedAt: DateTime
|
public updatedAt: DateTime
|
||||||
|
|
||||||
@beforeSave()
|
@beforeSave()
|
||||||
public static async hashPassword(user: User) {
|
public static async hashPassword(user: User) {
|
||||||
if (user.$dirty.password) {
|
if (user.$dirty.password)
|
||||||
user.password = await Hash.make(user.password)
|
user.password = await Hash.make(user.password)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
app/Tasks/SongsTask.ts
Normal file
13
app/Tasks/SongsTask.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import Logger from '@ioc:Adonis/Core/Logger'
|
||||||
|
|
||||||
|
const MS = 1000
|
||||||
|
|
||||||
|
export async function getCurrentPlayingMusic(): Promise<void> {
|
||||||
|
// Fetch from deezer
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function Activate(): Promise<void> {
|
||||||
|
Logger.info(`Starting task runner for watching deezer current playing [${MS} ms]`)
|
||||||
|
await getCurrentPlayingMusic()
|
||||||
|
setInterval(getCurrentPlayingMusic, MS)
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import axios from "axios";
|
import { btoa } from 'buffer'
|
||||||
import Env from "@ioc:Adonis/Core/Env";
|
import axios from 'axios'
|
||||||
import Logger from "@ioc:Adonis/Core/Logger";
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
import Redis from "@ioc:Adonis/Addons/Redis";
|
import Logger from '@ioc:Adonis/Core/Logger'
|
||||||
import {btoa} from "buffer";
|
import Redis from '@ioc:Adonis/Addons/Redis'
|
||||||
|
|
||||||
const MS = 1000 * 2 * 60 // 2 min
|
const MS = 1000 * 2 * 60 // 2 min
|
||||||
let taskId
|
let taskId
|
||||||
@@ -14,16 +14,16 @@ interface StatesResponse {
|
|||||||
async function getCurrentTime(): Promise<void> {
|
async function getCurrentTime(): Promise<void> {
|
||||||
const response = await axios.get<{ data: StatesResponse[]}>(`https://wakatime.com/api/v1/users/${Env.get('WAKATIME_USER')}/heartbeats`, {
|
const response = await axios.get<{ data: StatesResponse[]}>(`https://wakatime.com/api/v1/users/${Env.get('WAKATIME_USER')}/heartbeats`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Basic ${btoa(Env.get('WAKATIME_KEY'))}`
|
Authorization: `Basic ${btoa(Env.get('WAKATIME_KEY'))}`,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
'date': new Date()
|
date: new Date(),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
const heartbeat = response.data.data[response.data.data.length -1]
|
const heartbeat = response.data.data[response.data.data.length - 1]
|
||||||
const current_time = new Date(Date.now()).getTime()/1000
|
const current_time = new Date(Date.now()).getTime() / 1000
|
||||||
|
|
||||||
if (heartbeat.time) {
|
if (heartbeat.time) {
|
||||||
const active = current_time - heartbeat.time <= 60 * 5 // Less than 5 min.
|
const active = current_time - heartbeat.time <= 60 * 5 // Less than 5 min.
|
||||||
@@ -41,10 +41,9 @@ export async function Activate(): Promise<void> {
|
|||||||
Logger.info(`Starting task runner for getting current developing state [every ${MS} ms]`)
|
Logger.info(`Starting task runner for getting current developing state [every ${MS} ms]`)
|
||||||
await getCurrentTime()
|
await getCurrentTime()
|
||||||
taskId = setInterval(getCurrentTime, MS)
|
taskId = setInterval(getCurrentTime, MS)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ShutDown(): void {
|
export function ShutDown(): void {
|
||||||
clearInterval(taskId)
|
clearInterval(taskId)
|
||||||
Logger.info(`Shutdown task runner for getting current developing state`)
|
Logger.info('Shutdown task runner for getting current developing state')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Logger from "@ioc:Adonis/Core/Logger";
|
import Logger from '@ioc:Adonis/Core/Logger'
|
||||||
import Env from "@ioc:Adonis/Core/Env";
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
import axios from "axios";
|
import axios from 'axios'
|
||||||
import DevelopmentHour from "App/Models/DevelopmentHour";
|
import DevelopmentHour from 'App/Models/DevelopmentHour'
|
||||||
|
|
||||||
const MS = 1000 * 5 * 60 // 5 min
|
const MS = 1000 * 5 * 60 // 5 min
|
||||||
let taskId
|
let taskId
|
||||||
@@ -20,16 +20,16 @@ async function getDevelopmentHours(): Promise<void> {
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
const mapped_stats = response.data.data.map((item: StatsResponse) => {
|
const mapped_stats = response.data.data.map((item: StatsResponse) => {
|
||||||
return {
|
return {
|
||||||
seconds: item.grand_total.total_seconds, date: item.range.date
|
seconds: item.grand_total.total_seconds, date: item.range.date,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const data of mapped_stats) {
|
for (const data of mapped_stats) {
|
||||||
await DevelopmentHour.updateOrCreate({
|
await DevelopmentHour.updateOrCreate({
|
||||||
date: data.date.split('T')[0]
|
date: data.date.split('T')[0],
|
||||||
}, {
|
}, {
|
||||||
date: data.date.split('T')[0],
|
date: data.date.split('T')[0],
|
||||||
seconds: data.seconds
|
seconds: data.seconds,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,10 +39,9 @@ export async function Activate(): Promise<void> {
|
|||||||
Logger.info(`Starting task runner for getting development hours [every ${MS} ms]`)
|
Logger.info(`Starting task runner for getting development hours [every ${MS} ms]`)
|
||||||
await getDevelopmentHours()
|
await getDevelopmentHours()
|
||||||
taskId = setInterval(getDevelopmentHours, MS)
|
taskId = setInterval(getDevelopmentHours, MS)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ShutDown(): void {
|
export function ShutDown(): void {
|
||||||
clearInterval(taskId)
|
clearInterval(taskId)
|
||||||
Logger.info(`Shutdown task runner for getting development hours`)
|
Logger.info('Shutdown task runner for getting development hours')
|
||||||
}
|
}
|
||||||
|
|||||||
11
app/Utils/SongUtils.ts
Normal file
11
app/Utils/SongUtils.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export async function getHistory(range: 'day' | 'week' | 'month') {
|
||||||
|
return range
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getTopTrack() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GetCurrentPlaying() {
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
import DevelopmentHour from "App/Models/DevelopmentHour";
|
import DevelopmentHour from 'App/Models/DevelopmentHour'
|
||||||
import CommandsRun from "App/Models/CommandsRun";
|
import CommandsRun from 'App/Models/CommandsRun'
|
||||||
import BuildsRun from "App/Models/BuildsRun";
|
import BuildsRun from 'App/Models/BuildsRun'
|
||||||
|
|
||||||
|
interface Time {
|
||||||
|
total_hours: number
|
||||||
|
total_minutes: number
|
||||||
|
total_seconds: number
|
||||||
|
}
|
||||||
|
|
||||||
interface Stats {
|
interface Stats {
|
||||||
range: {
|
range: {
|
||||||
@@ -13,12 +19,6 @@ interface Stats {
|
|||||||
builds_ran: number
|
builds_ran: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Time {
|
|
||||||
total_hours: number
|
|
||||||
total_minutes: number
|
|
||||||
total_seconds: number
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(date: Date): string {
|
function formatDate(date: Date): string {
|
||||||
return date.toISOString().split('T')[0]
|
return date.toISOString().split('T')[0]
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ export async function getDevelopmentHours(start: string, end: string): Promise<T
|
|||||||
return {
|
return {
|
||||||
total_hours: 0,
|
total_hours: 0,
|
||||||
total_minutes: 0,
|
total_minutes: 0,
|
||||||
total_seconds: 0
|
total_seconds: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ export async function getDevelopmentHours(start: string, end: string): Promise<T
|
|||||||
return {
|
return {
|
||||||
total_hours: Math.floor(total / 3600),
|
total_hours: Math.floor(total / 3600),
|
||||||
total_minutes: Math.floor(total / 60),
|
total_minutes: Math.floor(total / 60),
|
||||||
total_seconds: Math.floor(total)
|
total_seconds: Math.floor(total),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,9 +57,8 @@ export async function getCommandsRan(start: string, end: string): Promise<number
|
|||||||
.where('date', '<=', end)
|
.where('date', '<=', end)
|
||||||
.orderBy('date', 'desc')
|
.orderBy('date', 'desc')
|
||||||
|
|
||||||
if (!commands_run) {
|
if (!commands_run)
|
||||||
return 0
|
return 0
|
||||||
}
|
|
||||||
|
|
||||||
let commands = 0
|
let commands = 0
|
||||||
commands_run.forEach(item => commands += item.commands)
|
commands_run.forEach(item => commands += item.commands)
|
||||||
@@ -74,9 +73,8 @@ export async function getBuildsRan(start: string, end: string): Promise<number>
|
|||||||
.where('date', '<=', end)
|
.where('date', '<=', end)
|
||||||
.orderBy('date', 'desc')
|
.orderBy('date', 'desc')
|
||||||
|
|
||||||
if (!builds_run) {
|
if (!builds_run)
|
||||||
return 0
|
return 0
|
||||||
}
|
|
||||||
|
|
||||||
let builds = 0
|
let builds = 0
|
||||||
builds_run.forEach(item => builds += item.builds)
|
builds_run.forEach(item => builds += item.builds)
|
||||||
@@ -85,7 +83,7 @@ export async function getBuildsRan(start: string, end: string): Promise<number>
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchStatistics(): Promise<Stats> {
|
export async function fetchStatistics(): Promise<Stats> {
|
||||||
const start = formatDate(new Date("2020-10-13"))
|
const start = formatDate(new Date('2020-10-13'))
|
||||||
|
|
||||||
const development_time = await getDevelopmentHours(start, NOW)
|
const development_time = await getDevelopmentHours(start, NOW)
|
||||||
const commands_ran = await getCommandsRan(start, NOW)
|
const commands_ran = await getCommandsRan(start, NOW)
|
||||||
@@ -98,7 +96,7 @@ export async function fetchStatistics(): Promise<Stats> {
|
|||||||
},
|
},
|
||||||
development_time,
|
development_time,
|
||||||
commands_ran,
|
commands_ran,
|
||||||
builds_ran
|
builds_ran,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ export async function fetchMonthlyStatistics(): Promise<Stats> {
|
|||||||
},
|
},
|
||||||
development_time,
|
development_time,
|
||||||
commands_ran,
|
commands_ran,
|
||||||
builds_ran
|
builds_ran,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ export async function fetchWeeklyStatistics(): Promise<Stats> {
|
|||||||
},
|
},
|
||||||
development_time,
|
development_time,
|
||||||
commands_ran,
|
commands_ran,
|
||||||
builds_ran
|
builds_ran,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +148,6 @@ export async function fetchDailyStatistics(): Promise<Stats> {
|
|||||||
},
|
},
|
||||||
development_time,
|
development_time,
|
||||||
commands_ran,
|
commands_ran,
|
||||||
builds_ran
|
builds_ran,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Translation from "App/Models/Translation";
|
import Translation from 'App/Models/Translation'
|
||||||
|
|
||||||
export async function getTranslation(code: string): Promise<Translation> {
|
export async function getTranslation(code: string): Promise<Translation> {
|
||||||
return await Translation.firstOrNew({code}, {code})
|
return await Translation.firstOrNew({ code }, { code })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
import { rules, schema } from '@ioc:Adonis/Core/Validator'
|
||||||
|
|
||||||
export default class AuthValidator {
|
export default class AuthValidator {
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
email: schema.string({ trim: true }, [
|
email: schema.string({ trim: true }, [
|
||||||
rules.email(),
|
rules.email(),
|
||||||
rules.required()
|
rules.required(),
|
||||||
]),
|
]),
|
||||||
password: schema.string({ trim: true }, [
|
password: schema.string({ trim: true }, [
|
||||||
rules.required()
|
rules.required(),
|
||||||
]),
|
]),
|
||||||
remember: schema.boolean.optional()
|
remember: schema.boolean.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class AnnounceUpdateValidator {
|
export default class AnnounceUpdateValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
code: schema.string.optional(),
|
code: schema.string.optional(),
|
||||||
cover: schema.string.optional(),
|
cover: schema.string.optional(),
|
||||||
color: schema.string.optional(),
|
color: schema.string.optional(),
|
||||||
hoverColor: schema.string.optional()
|
hoverColor: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class ExperienceStoreValidator {
|
export default class ExperienceStoreValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -10,10 +10,10 @@ export default class ExperienceStoreValidator {
|
|||||||
company: schema.string(),
|
company: schema.string(),
|
||||||
location: schema.string(),
|
location: schema.string(),
|
||||||
beginDate: schema.string(),
|
beginDate: schema.string(),
|
||||||
endDate: schema.string()
|
endDate: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class ExperienceUpdateValidator {
|
export default class ExperienceUpdateValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -10,10 +10,10 @@ export default class ExperienceUpdateValidator {
|
|||||||
company: schema.string.optional(),
|
company: schema.string.optional(),
|
||||||
location: schema.string.optional(),
|
location: schema.string.optional(),
|
||||||
beginDate: schema.string.optional(),
|
beginDate: schema.string.optional(),
|
||||||
endDate: schema.string.optional()
|
endDate: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class FormStoreValidator {
|
export default class FormStoreValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
name: schema.string(),
|
name: schema.string(),
|
||||||
email: schema.string(),
|
email: schema.string(),
|
||||||
subject: schema.string(),
|
subject: schema.string(),
|
||||||
content: schema.string()
|
content: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class FormationStoreValidator {
|
export default class FormationStoreValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -10,10 +10,10 @@ export default class FormationStoreValidator {
|
|||||||
description: schema.string(),
|
description: schema.string(),
|
||||||
location: schema.string(),
|
location: schema.string(),
|
||||||
beginDate: schema.string(),
|
beginDate: schema.string(),
|
||||||
endDate: schema.string()
|
endDate: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class FormationUpdateValidator {
|
export default class FormationUpdateValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -10,10 +10,10 @@ export default class FormationUpdateValidator {
|
|||||||
description: schema.string.optional(),
|
description: schema.string.optional(),
|
||||||
location: schema.string.optional(),
|
location: schema.string.optional(),
|
||||||
beginDate: schema.string.optional(),
|
beginDate: schema.string.optional(),
|
||||||
endDate: schema.string.optional()
|
endDate: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class InformationUpdateValidator {
|
export default class InformationUpdateValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
age: schema.number.optional(),
|
age: schema.number.optional(),
|
||||||
code: schema.string.optional()
|
code: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
|
|
||||||
export default class LocationValidator {
|
export default class LocationValidator {
|
||||||
constructor (private ctx: HttpContextContract) {
|
constructor(private ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -14,6 +14,6 @@ export default class LocationValidator {
|
|||||||
public cacheKey = this.ctx.routeKey
|
public cacheKey = this.ctx.routeKey
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class MaintenanceUpdateValidator {
|
export default class MaintenanceUpdateValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
reason: schema.string.optional(),
|
reason: schema.string.optional(),
|
||||||
active: schema.boolean.optional()
|
active: schema.boolean.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class PostStoreValidator {
|
export default class PostStoreValidator {
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
slug: schema.string(),
|
slug: schema.string(),
|
||||||
likes: schema.number(),
|
likes: schema.number(),
|
||||||
@@ -13,12 +12,13 @@ export default class PostStoreValidator {
|
|||||||
readingTime: schema.number(),
|
readingTime: schema.number(),
|
||||||
date: schema.string(),
|
date: schema.string(),
|
||||||
color: schema.string(),
|
color: schema.string(),
|
||||||
content: schema.string()
|
content: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class PostUpdateValidator {
|
export default class PostUpdateValidator {
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
slug: schema.string.optional(),
|
slug: schema.string.optional(),
|
||||||
likes: schema.number.optional(),
|
likes: schema.number.optional(),
|
||||||
@@ -13,12 +12,13 @@ export default class PostUpdateValidator {
|
|||||||
readingTime: schema.number.optional(),
|
readingTime: schema.number.optional(),
|
||||||
date: schema.string.optional(),
|
date: schema.string.optional(),
|
||||||
color: schema.string.optional(),
|
color: schema.string.optional(),
|
||||||
content: schema.string.optional()
|
content: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class PostColorStoreValidator {
|
export default class PostColorStoreValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -10,6 +10,6 @@ export default class PostColorStoreValidator {
|
|||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class PostColorUpdateValidator {
|
export default class PostColorUpdateValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -7,9 +7,9 @@ export default class PostColorUpdateValidator {
|
|||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class ProjectStoreValidator {
|
export default class ProjectStoreValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -10,10 +10,10 @@ export default class ProjectStoreValidator {
|
|||||||
description: schema.string(),
|
description: schema.string(),
|
||||||
url: schema.string(),
|
url: schema.string(),
|
||||||
cover: schema.string(),
|
cover: schema.string(),
|
||||||
tags: schema.array.optional().members(schema.string())
|
tags: schema.array.optional().members(schema.string()),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class ProjectUpdateValidator {
|
export default class ProjectUpdateValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -7,12 +7,13 @@ export default class ProjectUpdateValidator {
|
|||||||
description: schema.string.optional(),
|
description: schema.string.optional(),
|
||||||
url: schema.string.optional(),
|
url: schema.string.optional(),
|
||||||
cover: schema.string.optional(),
|
cover: schema.string.optional(),
|
||||||
tags: schema.array.optional().members(schema.string())
|
tags: schema.array.optional().members(schema.string()),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class SkillStoreValidator {
|
export default class SkillStoreValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
name: schema.string(),
|
name: schema.string(),
|
||||||
cover: schema.string(),
|
cover: schema.string(),
|
||||||
color: schema.string()
|
color: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class SkillUpdateValidator {
|
export default class SkillUpdateValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
name: schema.string.optional(),
|
name: schema.string.optional(),
|
||||||
cover: schema.string.optional(),
|
cover: schema.string.optional(),
|
||||||
color: schema.string.optional()
|
color: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class StateSleepingValidator {
|
export default class StateSleepingValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
value: schema.boolean()
|
value: schema.boolean(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
import { rules, schema } from '@ioc:Adonis/Core/Validator'
|
||||||
|
|
||||||
export default class SubscriberStoreValidator {
|
export default class SubscriberStoreValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -7,15 +7,15 @@ export default class SubscriberStoreValidator {
|
|||||||
rules.email(),
|
rules.email(),
|
||||||
rules.unique({
|
rules.unique({
|
||||||
table: 'subscribers',
|
table: 'subscribers',
|
||||||
column: 'email'
|
column: 'email',
|
||||||
})
|
}),
|
||||||
])
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class TagStoreValidator {
|
export default class TagStoreValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
label: schema.string()
|
label: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { schema } from '@ioc:Adonis/Core/Validator'
|
|||||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class TagUpdateValidator {
|
export default class TagUpdateValidator {
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
label: schema.string.optional()
|
label: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
import { rules, schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class TranslationStoreValidator {
|
export default class TranslationStoreValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
code: schema.string({}, [
|
code: schema.string({}, [
|
||||||
rules.unique({
|
rules.unique({
|
||||||
table: 'translations',
|
table: 'translations',
|
||||||
column: 'code'
|
column: 'code',
|
||||||
})
|
}),
|
||||||
]),
|
]),
|
||||||
english: schema.string.optional(),
|
english: schema.string.optional(),
|
||||||
french: schema.string.optional()
|
french: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required',
|
'required': 'The field {{field}} is required',
|
||||||
'code.unique': 'The translation code is not unique !'
|
'code.unique': 'The translation code is not unique !',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
import { rules, schema } from '@ioc:Adonis/Core/Validator'
|
||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
|
||||||
export default class TranslationUpdateValidator {
|
export default class TranslationUpdateValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
code: schema.string({}, [
|
code: schema.string({}, [
|
||||||
rules.unique({
|
rules.unique({
|
||||||
table: 'translations',
|
table: 'translations',
|
||||||
column: 'code'
|
column: 'code',
|
||||||
})
|
}),
|
||||||
]),
|
]),
|
||||||
english: schema.string.optional(),
|
english: schema.string.optional(),
|
||||||
french: schema.string.optional()
|
french: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required',
|
'required': 'The field {{field}} is required',
|
||||||
'code.unique': 'The translation code is not unique !'
|
'code.unique': 'The translation code is not unique !',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
import { rules, schema } from '@ioc:Adonis/Core/Validator'
|
||||||
|
|
||||||
export default class UserStoreValidator {
|
export default class UserStoreValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -8,17 +8,17 @@ export default class UserStoreValidator {
|
|||||||
rules.required(),
|
rules.required(),
|
||||||
rules.unique({
|
rules.unique({
|
||||||
table: 'users',
|
table: 'users',
|
||||||
column: 'email'
|
column: 'email',
|
||||||
})
|
}),
|
||||||
])
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required',
|
'required': 'The field {{field}} is required',
|
||||||
'email.email': 'The email must be valid',
|
'email.email': 'The email must be valid',
|
||||||
'email.unique': 'The email is not unique'
|
'email.unique': 'The email is not unique',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
import { rules, schema } from '@ioc:Adonis/Core/Validator'
|
||||||
|
|
||||||
export default class UserUpdateValidator {
|
export default class UserUpdateValidator {
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
@@ -9,14 +9,14 @@ export default class UserUpdateValidator {
|
|||||||
rules.unique(
|
rules.unique(
|
||||||
{
|
{
|
||||||
table: 'users',
|
table: 'users',
|
||||||
column: 'email'
|
column: 'email',
|
||||||
})
|
}),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
password: schema.string.optional({ trim: true, escape: true },
|
password: schema.string.optional({ trim: true, escape: true },
|
||||||
[
|
[
|
||||||
rules.confirmed()
|
rules.confirmed(),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
is_confirmed: schema.boolean.optional(),
|
is_confirmed: schema.boolean.optional(),
|
||||||
confirmation_token: schema.string.optional({ trim: true, escape: true }),
|
confirmation_token: schema.string.optional({ trim: true, escape: true }),
|
||||||
@@ -24,11 +24,11 @@ export default class UserUpdateValidator {
|
|||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required',
|
'required': 'The field {{field}} is required',
|
||||||
'email.email': 'The email must be valid',
|
'email.email': 'The email must be valid',
|
||||||
'password.confirmation': 'Passwords are not the same'
|
'password.confirmation': 'Passwords are not the same',
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (protected ctx: HttpContextContract) {
|
constructor(protected ctx: HttpContextContract) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
import proxyAddr from 'proxy-addr'
|
import proxyAddr from 'proxy-addr'
|
||||||
import Env from '@ioc:Adonis/Core/Env'
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
import {ServerConfig} from '@ioc:Adonis/Core/Server'
|
import { ServerConfig } from '@ioc:Adonis/Core/Server'
|
||||||
import {LoggerConfig} from '@ioc:Adonis/Core/Logger'
|
import { LoggerConfig } from '@ioc:Adonis/Core/Logger'
|
||||||
import {ProfilerConfig} from '@ioc:Adonis/Core/Profiler'
|
import { ProfilerConfig } from '@ioc:Adonis/Core/Profiler'
|
||||||
import {ValidatorConfig} from '@ioc:Adonis/Core/Validator'
|
import { ValidatorConfig } from '@ioc:Adonis/Core/Validator'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -105,7 +105,7 @@ export const http: ServerConfig = {
|
|||||||
path: '/',
|
path: '/',
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
sameSite: 'none',
|
sameSite: 'none',
|
||||||
secure: Env.get('NODE_ENV') === 'production'
|
secure: Env.get('NODE_ENV') === 'production',
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {AuthConfig} from '@ioc:Adonis/Addons/Auth'
|
import { AuthConfig } from '@ioc:Adonis/Addons/Auth'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -115,7 +115,7 @@ const authConfig: AuthConfig = {
|
|||||||
tokenProvider: {
|
tokenProvider: {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
driver: 'redis',
|
driver: 'redis',
|
||||||
redisConnection: 'local'
|
redisConnection: 'local',
|
||||||
},
|
},
|
||||||
|
|
||||||
provider: {
|
provider: {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {BodyParserConfig} from '@ioc:Adonis/Core/BodyParser'
|
import { BodyParserConfig } from '@ioc:Adonis/Core/BodyParser'
|
||||||
|
|
||||||
const bodyParserConfig: BodyParserConfig = {
|
const bodyParserConfig: BodyParserConfig = {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {CorsConfig} from '@ioc:Adonis/Core/Cors'
|
import { CorsConfig } from '@ioc:Adonis/Core/Cors'
|
||||||
|
|
||||||
const corsConfig: CorsConfig = {
|
const corsConfig: CorsConfig = {
|
||||||
/*
|
/*
|
||||||
@@ -44,12 +44,12 @@ const corsConfig: CorsConfig = {
|
|||||||
| one of the above values.
|
| one of the above values.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
origin: (origin => {
|
origin: (origin) => {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development')
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
return origin.includes('arthurdanjou.fr')
|
return origin.includes('arthurdanjou.fr')
|
||||||
}),
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Env from '@ioc:Adonis/Core/Env'
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
import {DatabaseConfig} from '@ioc:Adonis/Lucid/Database'
|
import { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'
|
||||||
|
|
||||||
const databaseConfig: DatabaseConfig = {
|
const databaseConfig: DatabaseConfig = {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Env from '@ioc:Adonis/Core/Env'
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
import {HashConfig} from '@ioc:Adonis/Core/Hash'
|
import { HashConfig } from '@ioc:Adonis/Core/Hash'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -50,7 +50,7 @@ const hashConfig: HashConfig = {
|
|||||||
memory: 4096,
|
memory: 4096,
|
||||||
parallelism: 1,
|
parallelism: 1,
|
||||||
saltSize: 16,
|
saltSize: 16,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const mailConfig: MailConfig = {
|
|||||||
user: Env.get('SMTP_USERNAME'),
|
user: Env.get('SMTP_USERNAME'),
|
||||||
pass: Env.get('SMTP_PASSWORD'),
|
pass: Env.get('SMTP_PASSWORD'),
|
||||||
type: 'login',
|
type: 'login',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const redisConfig: RedisConfig = {
|
|||||||
password: Env.get('REDIS_PASSWORD', ''),
|
password: Env.get('REDIS_PASSWORD', ''),
|
||||||
db: Env.get('REDIS_DB', 0),
|
db: Env.get('REDIS_DB', 0),
|
||||||
keyPrefix: 'athena:',
|
keyPrefix: 'athena:',
|
||||||
healthCheck: true
|
healthCheck: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Env from '@ioc:Adonis/Core/Env'
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
import {SessionConfig} from '@ioc:Adonis/Addons/Session'
|
import { SessionConfig } from '@ioc:Adonis/Addons/Session'
|
||||||
|
|
||||||
const sessionConfig: SessionConfig = {
|
const sessionConfig: SessionConfig = {
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ const sessionConfig: SessionConfig = {
|
|||||||
path: '/',
|
path: '/',
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
sameSite: Env.get('NODE_ENV') === 'production' ? 'none' : false,
|
sameSite: Env.get('NODE_ENV') === 'production' ? 'none' : false,
|
||||||
secure: Env.get('NODE_ENV') === 'production'
|
secure: Env.get('NODE_ENV') === 'production',
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ declare module '@ioc:Adonis/Addons/Auth' {
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
user: {
|
user: {
|
||||||
implementation: LucidProviderContract<typeof User>,
|
implementation: LucidProviderContract<typeof User>
|
||||||
config: LucidProviderConfig<typeof User>,
|
config: LucidProviderConfig<typeof User>
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -65,9 +65,9 @@ declare module '@ioc:Adonis/Addons/Auth' {
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
web: {
|
web: {
|
||||||
implementation: SessionGuardContract<'user', 'web'>,
|
implementation: SessionGuardContract<'user', 'web'>
|
||||||
config: SessionGuardConfig<'user'>,
|
config: SessionGuardConfig<'user'>
|
||||||
},
|
}
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| OAT Guard
|
| OAT Guard
|
||||||
@@ -78,8 +78,8 @@ declare module '@ioc:Adonis/Addons/Auth' {
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
api: {
|
api: {
|
||||||
implementation: OATGuardContract<'user', 'api'>,
|
implementation: OATGuardContract<'user', 'api'>
|
||||||
config: OATGuardConfig<'user'>,
|
config: OATGuardConfig<'user'>
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,13 @@
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {actions, policies} from '../start/bouncer'
|
import { actions, policies } from '../start/bouncer'
|
||||||
|
|
||||||
declare module '@ioc:Adonis/Addons/Bouncer' {
|
declare module '@ioc:Adonis/Addons/Bouncer' {
|
||||||
type ApplicationActions = ExtractActionsTypes<typeof actions>
|
type ApplicationActions = ExtractActionsTypes<typeof actions>
|
||||||
type ApplicationPolicies = ExtractPoliciesTypes<typeof policies>
|
type ApplicationPolicies = ExtractPoliciesTypes<typeof policies>
|
||||||
|
|
||||||
interface ActionsList extends ApplicationActions {
|
interface ActionsList extends ApplicationActions {}
|
||||||
}
|
|
||||||
|
|
||||||
interface PoliciesList extends ApplicationPolicies {
|
interface PoliciesList extends ApplicationPolicies {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
declare module '@ioc:Adonis/Core/Env' {
|
declare module '@ioc:Adonis/Core/Env' {
|
||||||
/*
|
type CustomTypes = typeof import('../env').default
|
||||||
|--------------------------------------------------------------------------
|
interface EnvTypes extends CustomTypes {}
|
||||||
| Getting types for validated environment variables
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| The `default` export from the "../env.ts" file exports types for the
|
|
||||||
| validated environment variables. Here we merge them with the `EnvTypes`
|
|
||||||
| interface so that you can enjoy intellisense when using the "Env"
|
|
||||||
| module.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
type CustomTypes = typeof import("../env").default;
|
|
||||||
interface EnvTypes extends CustomTypes {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ declare module '@ioc:Adonis/Core/Hash' {
|
|||||||
|
|
||||||
interface HashersList {
|
interface HashersList {
|
||||||
argon: {
|
argon: {
|
||||||
config: ArgonConfig,
|
config: ArgonConfig
|
||||||
implementation: ArgonContract,
|
implementation: ArgonContract
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ declare module '@ioc:Adonis/Addons/Mail' {
|
|||||||
import { MailDrivers } from '@ioc:Adonis/Addons/Mail'
|
import { MailDrivers } from '@ioc:Adonis/Addons/Mail'
|
||||||
|
|
||||||
interface MailersList {
|
interface MailersList {
|
||||||
smtp: MailDrivers['smtp'],
|
smtp: MailDrivers['smtp']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
|
|
||||||
declare module '@ioc:Adonis/Addons/Redis' {
|
declare module '@ioc:Adonis/Addons/Redis' {
|
||||||
interface RedisConnectionsList {
|
interface RedisConnectionsList {
|
||||||
local: RedisConnectionConfig,
|
local: RedisConnectionConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Translations extends BaseSchema {
|
export default class Translations extends BaseSchema {
|
||||||
protected tableName = 'translations'
|
protected tableName = 'translations'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('code').notNullable()
|
table.string('code').notNullable()
|
||||||
@@ -13,7 +13,7 @@ export default class Translations extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Subscribers extends BaseSchema {
|
export default class Subscribers extends BaseSchema {
|
||||||
protected tableName = 'subscribers'
|
protected tableName = 'subscribers'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('email').notNullable()
|
table.string('email').notNullable()
|
||||||
@@ -11,7 +11,7 @@ export default class Subscribers extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Pictures extends BaseSchema {
|
export default class Pictures extends BaseSchema {
|
||||||
protected tableName = 'files'
|
protected tableName = 'files'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('label').notNullable()
|
table.string('label').notNullable()
|
||||||
@@ -12,7 +12,7 @@ export default class Pictures extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Locations extends BaseSchema {
|
export default class Locations extends BaseSchema {
|
||||||
protected tableName = 'locations'
|
protected tableName = 'locations'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('place').notNullable()
|
table.string('place').notNullable()
|
||||||
@@ -13,7 +13,7 @@ export default class Locations extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Projects extends BaseSchema {
|
export default class Projects extends BaseSchema {
|
||||||
protected tableName = 'projects'
|
protected tableName = 'projects'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('name').notNullable()
|
table.string('name').notNullable()
|
||||||
@@ -22,7 +22,7 @@ export default class Projects extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Forms extends BaseSchema {
|
export default class Forms extends BaseSchema {
|
||||||
protected tableName = 'forms'
|
protected tableName = 'forms'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('name').notNullable()
|
table.string('name').notNullable()
|
||||||
@@ -14,7 +14,7 @@ export default class Forms extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
import Hash from "@ioc:Adonis/Core/Hash";
|
import Hash from '@ioc:Adonis/Core/Hash'
|
||||||
|
|
||||||
export default class Users extends BaseSchema {
|
export default class Users extends BaseSchema {
|
||||||
protected tableName = 'users'
|
protected tableName = 'users'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('username', 255).notNullable()
|
table.string('username', 255).notNullable()
|
||||||
@@ -20,7 +20,7 @@ export default class Users extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,12 +28,12 @@ export default class Users extends BaseSchema {
|
|||||||
let password = ''
|
let password = ''
|
||||||
const char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.:=+-_$*^&@#%ù/àçè()é"'
|
const char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.:=+-_$*^&@#%ù/àçè()é"'
|
||||||
const size = 64
|
const size = 64
|
||||||
for (let i = 0; i < size; i++) {
|
for (let i = 0; i < size; i++)
|
||||||
password += char.charAt(Math.random() * char.length)
|
password += char.charAt(Math.random() * char.length)
|
||||||
}
|
|
||||||
Hash.make(password).then((value => {
|
Hash.make(password).then((value) => {
|
||||||
password = value
|
password = value
|
||||||
}))
|
})
|
||||||
return password
|
return password
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Announces extends BaseSchema {
|
export default class Announces extends BaseSchema {
|
||||||
protected tableName = 'announces'
|
protected tableName = 'announces'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('color').notNullable()
|
table.string('color').notNullable()
|
||||||
@@ -22,7 +22,7 @@ export default class Announces extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Skills extends BaseSchema {
|
export default class Skills extends BaseSchema {
|
||||||
protected tableName = 'skills'
|
protected tableName = 'skills'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('name').notNullable()
|
table.string('name').notNullable()
|
||||||
@@ -17,7 +17,7 @@ export default class Skills extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Informations extends BaseSchema {
|
export default class Informations extends BaseSchema {
|
||||||
protected tableName = 'informations'
|
protected tableName = 'informations'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.integer('age').notNullable()
|
table.integer('age').notNullable()
|
||||||
@@ -16,7 +16,7 @@ export default class Informations extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Experiences extends BaseSchema {
|
export default class Experiences extends BaseSchema {
|
||||||
protected tableName = 'experiences'
|
protected tableName = 'experiences'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table
|
table
|
||||||
@@ -19,7 +19,7 @@ export default class Experiences extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Formations extends BaseSchema {
|
export default class Formations extends BaseSchema {
|
||||||
protected tableName = 'formations'
|
protected tableName = 'formations'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table
|
table
|
||||||
@@ -23,7 +23,7 @@ export default class Formations extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Tags extends BaseSchema {
|
export default class Tags extends BaseSchema {
|
||||||
protected tableName = 'tags'
|
protected tableName = 'tags'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table
|
table
|
||||||
@@ -15,7 +15,7 @@ export default class Tags extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
|||||||
export default class Posts extends BaseSchema {
|
export default class Posts extends BaseSchema {
|
||||||
protected tableName = 'posts'
|
protected tableName = 'posts'
|
||||||
|
|
||||||
public async up () {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('slug').notNullable()
|
table.string('slug').notNullable()
|
||||||
@@ -29,7 +29,7 @@ export default class Posts extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down() {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user