mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-30 03:17:50 +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,11 +1,10 @@
|
|||||||
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()
|
||||||
@@ -14,7 +13,7 @@ export default class AnnouncesController {
|
|||||||
.preload('cover')
|
.preload('cover')
|
||||||
.first()
|
.first()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
announce: announce
|
announce,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,9 +21,8 @@ export default class AnnouncesController {
|
|||||||
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,15 +1,14 @@
|
|||||||
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(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ export default class AuthController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,28 +25,28 @@ export default class AuthController {
|
|||||||
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,18 +1,17 @@
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ export default class ExperiencesController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ export default class ExperiencesController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,14 +37,13 @@ export default class ExperiencesController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,8 +51,7 @@ export default class ExperiencesController {
|
|||||||
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,40 +1,38 @@
|
|||||||
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,
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +40,7 @@ export default class FilesController {
|
|||||||
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,11 +1,10 @@
|
|||||||
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()
|
||||||
@@ -13,7 +12,7 @@ export default class FormationsController {
|
|||||||
.preload('title')
|
.preload('title')
|
||||||
.preload('description')
|
.preload('description')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
formations: formations
|
formations,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ export default class FormationsController {
|
|||||||
formation.load('title')
|
formation.load('title')
|
||||||
formation.load('description')
|
formation.load('description')
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
formation
|
formation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,18 +41,16 @@ export default class FormationsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +58,7 @@ export default class FormationsController {
|
|||||||
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,12 +1,11 @@
|
|||||||
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'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,13 +13,13 @@ export default class FormsController {
|
|||||||
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),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,8 +27,7 @@ export default class FormsController {
|
|||||||
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,16 +1,15 @@
|
|||||||
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(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,9 +1,8 @@
|
|||||||
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) {
|
||||||
@@ -11,12 +10,13 @@ export default class LocationsController {
|
|||||||
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...',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,7 @@ export default class LocationsController {
|
|||||||
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,10 +1,9 @@
|
|||||||
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()
|
||||||
@@ -12,7 +11,7 @@ export default class MaintenancesController {
|
|||||||
.preload('reason')
|
.preload('reason')
|
||||||
.first()
|
.first()
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
maintenance: maintenance
|
maintenance,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,15 +19,13 @@ export default class MaintenancesController {
|
|||||||
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,13 +1,12 @@
|
|||||||
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(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,14 +14,14 @@ export default class PostColorsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +30,7 @@ export default class PostColorsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,8 +38,7 @@ export default class PostColorsController {
|
|||||||
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,13 +1,12 @@
|
|||||||
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()
|
||||||
@@ -19,7 +18,7 @@ export default class PostsController {
|
|||||||
.preload('color')
|
.preload('color')
|
||||||
.preload('content')
|
.preload('content')
|
||||||
.preload('title')
|
.preload('title')
|
||||||
.preload('description')
|
.preload('description'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,7 +74,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +96,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,23 +104,23 @@ export default class PostsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,11 +128,10 @@ export default class PostsController {
|
|||||||
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,12 +1,11 @@
|
|||||||
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()
|
||||||
@@ -15,7 +14,7 @@ export default class ProjectsController {
|
|||||||
.preload('description')
|
.preload('description')
|
||||||
.preload('tags', (tags) => {
|
.preload('tags', (tags) => {
|
||||||
tags.preload('label')
|
tags.preload('label')
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ export default class ProjectsController {
|
|||||||
tags.preload('label')
|
tags.preload('label')
|
||||||
})
|
})
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
project
|
project,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +63,7 @@ export default class ProjectsController {
|
|||||||
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,17 +1,16 @@
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +30,7 @@ export default class SkillsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +51,7 @@ export default class SkillsController {
|
|||||||
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,9 +1,8 @@
|
|||||||
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) {
|
||||||
@@ -12,7 +11,7 @@ export default class StatesController {
|
|||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
sleeping,
|
sleeping,
|
||||||
developing,
|
developing,
|
||||||
listening_music: "Soon"
|
listening_music: 'Soon',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,12 +21,11 @@ export default class StatesController {
|
|||||||
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,16 +1,15 @@
|
|||||||
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()
|
||||||
@@ -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,21 +1,20 @@
|
|||||||
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),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,8 +22,7 @@ export default class SubscribersController {
|
|||||||
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,17 +1,16 @@
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ export default class TagsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ export default class TagsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,12 +37,11 @@ export default class TagsController {
|
|||||||
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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +49,7 @@ export default class TagsController {
|
|||||||
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,26 +1,25 @@
|
|||||||
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),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ export default class TranslationsController {
|
|||||||
await translation.merge(data).save()
|
await translation.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
translation
|
translation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +37,7 @@ export default class TranslationsController {
|
|||||||
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,26 +1,25 @@
|
|||||||
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),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ export default class UsersController {
|
|||||||
await user.merge(data).save()
|
await user.merge(data).save()
|
||||||
|
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
user
|
user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,14 +37,12 @@ export default class UsersController {
|
|||||||
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!',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
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()
|
||||||
}
|
}
|
||||||
@@ -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',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()) {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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,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,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>
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ export default class User extends BaseModel {
|
|||||||
|
|
||||||
@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,11 +14,11 @@ 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) {
|
||||||
@@ -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,4 +1,4 @@
|
|||||||
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 })
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ 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) {
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ export default class AnnounceUpdateValidator {
|
|||||||
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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ export default class FormStoreValidator {
|
|||||||
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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ 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) {
|
||||||
|
|||||||
@@ -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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ export default class MaintenanceUpdateValidator {
|
|||||||
|
|
||||||
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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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,10 +12,11 @@ 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) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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,10 +12,11 @@ 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) {
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ export default class PostColorStoreValidator {
|
|||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
required: 'The field {{field}} is required'
|
required: 'The field {{field}} is required',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ 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) {
|
||||||
|
|||||||
@@ -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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ 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) {
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ export default class SkillStoreValidator {
|
|||||||
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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ export default class SkillUpdateValidator {
|
|||||||
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',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default class StateSleepingValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
value: schema.boolean()
|
value: schema.boolean(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ 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) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default class TagStoreValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
label: schema.string()
|
label: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default class TagUpdateValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
label: schema.string.optional()
|
label: schema.string.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
public messages = {
|
public messages = {
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ export default class TranslationStoreValidator {
|
|||||||
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) {
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ export default class TranslationUpdateValidator {
|
|||||||
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) {
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ 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) {
|
||||||
|
|||||||
@@ -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,9 +24,9 @@ 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) {
|
||||||
|
|||||||
@@ -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',
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ const authConfig: AuthConfig = {
|
|||||||
tokenProvider: {
|
tokenProvider: {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
driver: 'redis',
|
driver: 'redis',
|
||||||
redisConnection: 'local'
|
redisConnection: 'local',
|
||||||
},
|
},
|
||||||
|
|
||||||
provider: {
|
provider: {
|
||||||
|
|||||||
@@ -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')
|
||||||
}),
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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'>
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
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'
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
env.ts
2
env.ts
@@ -59,5 +59,5 @@ export default Env.rules({
|
|||||||
// Wakatime
|
// Wakatime
|
||||||
WAKATIME_USER: Env.schema.string(),
|
WAKATIME_USER: Env.schema.string(),
|
||||||
WAKATIME_KEY: Env.schema.string(),
|
WAKATIME_KEY: Env.schema.string(),
|
||||||
WAKATIME_ID: Env.schema.string()
|
WAKATIME_ID: Env.schema.string(),
|
||||||
})
|
})
|
||||||
|
|||||||
21
package.json
21
package.json
@@ -8,15 +8,8 @@
|
|||||||
"dev": "node ace serve --watch",
|
"dev": "node ace serve --watch",
|
||||||
"seed": "node ace db:seed",
|
"seed": "node ace db:seed",
|
||||||
"mig": "node ace migration:run",
|
"mig": "node ace migration:run",
|
||||||
"lr": "node ace list:routes"
|
"lr": "node ace list:routes",
|
||||||
},
|
"lint": "npx eslint --ext .json,.ts --fix ."
|
||||||
"devDependencies": {
|
|
||||||
"@adonisjs/assembler": "^5.3.2",
|
|
||||||
"adonis-preset-ts": "^2.1.0",
|
|
||||||
"pino-pretty": "^5.0.2",
|
|
||||||
"typescript": "^4.3.4",
|
|
||||||
"youch": "^2.2.2",
|
|
||||||
"youch-terminal": "^1.1.1"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adonisjs/auth": "^8.0.6",
|
"@adonisjs/auth": "^8.0.6",
|
||||||
@@ -36,5 +29,15 @@
|
|||||||
"proxy-addr": "^2.0.7",
|
"proxy-addr": "^2.0.7",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"tslib": "^2.3.0"
|
"tslib": "^2.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@adonisjs/assembler": "^5.3.2",
|
||||||
|
"@antfu/eslint-config": "^0.10.0",
|
||||||
|
"adonis-preset-ts": "^2.1.0",
|
||||||
|
"eslint": "^8.2.0",
|
||||||
|
"pino-pretty": "^5.0.2",
|
||||||
|
"typescript": "^4.3.4",
|
||||||
|
"youch": "^2.2.2",
|
||||||
|
"youch-terminal": "^1.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
|
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
|
||||||
import Logger from "@ioc:Adonis/Core/Logger";
|
import Logger from '@ioc:Adonis/Core/Logger'
|
||||||
|
|
||||||
export default class AppProvider {
|
export default class AppProvider {
|
||||||
public static needsApplication = true
|
public static needsApplication = true
|
||||||
|
|||||||
@@ -1,10 +1,3 @@
|
|||||||
/**
|
|
||||||
* Contract source: https://git.io/Jte3T
|
|
||||||
*
|
|
||||||
* Feel free to let us know via PR, if you find something broken in this config
|
|
||||||
* file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Bouncer from '@ioc:Adonis/Addons/Bouncer'
|
import Bouncer from '@ioc:Adonis/Addons/Bouncer'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Server from "@ioc:Adonis/Core/Server";
|
import Server from '@ioc:Adonis/Core/Server'
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Global middleware
|
| Global middleware
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Route from "@ioc:Adonis/Core/Route";
|
import Route from '@ioc:Adonis/Core/Route'
|
||||||
import Application from "@ioc:Adonis/Core/Application";
|
import Application from '@ioc:Adonis/Core/Application'
|
||||||
|
|
||||||
Route.get('/me', 'ProfileController.me')
|
Route.get('/me', 'ProfileController.me')
|
||||||
Route.get('/stats', 'StatsController.index')
|
Route.get('/stats', 'StatsController.index')
|
||||||
@@ -21,7 +21,6 @@ Route.group(() => {
|
|||||||
Route.post('/commands', 'StatsController.incrementCommandCount')
|
Route.post('/commands', 'StatsController.incrementCommandCount')
|
||||||
Route.post('/builds', 'StatsController.incrementBuildCount')
|
Route.post('/builds', 'StatsController.incrementBuildCount')
|
||||||
}).prefix('stats')
|
}).prefix('stats')
|
||||||
|
|
||||||
}).middleware('auth:web,api')
|
}).middleware('auth:web,api')
|
||||||
|
|
||||||
Route.get('/files/:filename', async({ response, params }) => {
|
Route.get('/files/:filename', async({ response, params }) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import Route from "@ioc:Adonis/Core/Route";
|
import Route from '@ioc:Adonis/Core/Route'
|
||||||
|
|
||||||
Route.group(() => {
|
Route.group(() => {
|
||||||
Route.resource('/form', 'FormsController').except(['edit', 'create', 'update'])
|
Route.resource('/form', 'FormsController').except(['edit', 'create', 'update'])
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import Route from "@ioc:Adonis/Core/Route";
|
import Route from '@ioc:Adonis/Core/Route'
|
||||||
|
|
||||||
Route.group(() => {
|
Route.group(() => {
|
||||||
Route.get('/me', 'AuthController.user').middleware('auth:web,api')
|
Route.get('/me', 'AuthController.user').middleware('auth:web,api')
|
||||||
@@ -13,6 +13,4 @@ Route.group(() => {
|
|||||||
Route.post('/login', 'AuthController.loginWeb')
|
Route.post('/login', 'AuthController.loginWeb')
|
||||||
Route.post('/logout', 'AuthController.logoutWeb')
|
Route.post('/logout', 'AuthController.logoutWeb')
|
||||||
}).prefix('/web')
|
}).prefix('/web')
|
||||||
|
|
||||||
}).prefix('/auth')
|
}).prefix('/auth')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Env from "@ioc:Adonis/Core/Env";
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
import Route from "@ioc:Adonis/Core/Route";
|
import Route from '@ioc:Adonis/Core/Route'
|
||||||
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
import HealthCheck from "@ioc:Adonis/Core/HealthCheck";
|
import HealthCheck from '@ioc:Adonis/Core/HealthCheck'
|
||||||
|
|
||||||
const BASE_URL = Env.get('BASE_URL')
|
const BASE_URL = Env.get('BASE_URL')
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ Route.get('/', async ({response}: HttpContextContract) => {
|
|||||||
profile: `${BASE_URL}/me`,
|
profile: `${BASE_URL}/me`,
|
||||||
stats: `${BASE_URL}/stats`,
|
stats: `${BASE_URL}/stats`,
|
||||||
states: `${BASE_URL}/states`,
|
states: `${BASE_URL}/states`,
|
||||||
locations: `${BASE_URL}/locations`
|
locations: `${BASE_URL}/locations`,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -28,9 +28,11 @@ Route.get('/health', async ({response}: HttpContextContract) => {
|
|||||||
const report = await HealthCheck.getReport()
|
const report = await HealthCheck.getReport()
|
||||||
const isLive = await HealthCheck.isLive()
|
const isLive = await HealthCheck.isLive()
|
||||||
const isReady = HealthCheck.isReady()
|
const isReady = HealthCheck.isReady()
|
||||||
return report.healthy ? response.ok({isLive, isReady, report: report.report}) : response.badRequest({
|
return report.healthy
|
||||||
|
? response.ok({ isLive, isReady, report: report.report })
|
||||||
|
: response.badRequest({
|
||||||
isLive,
|
isLive,
|
||||||
isReady,
|
isReady,
|
||||||
report: report.report
|
report: report.report,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user