Initial commit
This commit is contained in:
48
app/controllers/experiences_controller.js
Normal file
48
app/controllers/experiences_controller.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import Experience from '#models/experience';
|
||||
export default class ExperiencesController {
|
||||
async index({ response }) {
|
||||
const experiences = await Experience.query()
|
||||
.preload('projects')
|
||||
.orderBy('start', 'desc');
|
||||
return response.ok({
|
||||
data: experiences.map((e) => ({
|
||||
id: e.id,
|
||||
name: e.name,
|
||||
start: e.start.toISODate(),
|
||||
end: e.end?.toISODate() ?? null,
|
||||
missions: e.missions,
|
||||
place: e.place,
|
||||
projects: e.projects.map((p) => ({
|
||||
id: p.id,
|
||||
title: p.title,
|
||||
thumbnailUrl: p.thumbnailUrl,
|
||||
})),
|
||||
})),
|
||||
});
|
||||
}
|
||||
async show({ params, response }) {
|
||||
const experience = await Experience.query()
|
||||
.where('id', params.id)
|
||||
.preload('projects')
|
||||
.first();
|
||||
if (!experience) {
|
||||
return response.notFound();
|
||||
}
|
||||
return response.ok({
|
||||
data: {
|
||||
id: experience.id,
|
||||
name: experience.name,
|
||||
start: experience.start.toISODate(),
|
||||
end: experience.end?.toISODate() ?? null,
|
||||
missions: experience.missions,
|
||||
place: experience.place,
|
||||
projects: experience.projects.map((p) => ({
|
||||
id: p.id,
|
||||
title: p.title,
|
||||
thumbnailUrl: p.thumbnailUrl,
|
||||
}))
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=experiences_controller.js.map
|
||||
Reference in New Issue
Block a user