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