diff options
author | 2024-02-10 18:19:14 -0700 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | 7584d2d7a7110aef0331ebfa178b2295842c59fa (patch) | |
tree | 900cd71237e6231b57936fcce77ff229cd459041 /app/Controllers/Http/Api/Static/AnnouncementsController.ts | |
parent | upgrade recipes submodule (diff) | |
download | ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.gz ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.zst ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.zip |
refactor: project maintenance
- work in progress
Diffstat (limited to 'app/Controllers/Http/Api/Static/AnnouncementsController.ts')
-rw-r--r-- | app/Controllers/Http/Api/Static/AnnouncementsController.ts | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/app/Controllers/Http/Api/Static/AnnouncementsController.ts b/app/Controllers/Http/Api/Static/AnnouncementsController.ts index c20707b..4ae9d0e 100644 --- a/app/Controllers/Http/Api/Static/AnnouncementsController.ts +++ b/app/Controllers/Http/Api/Static/AnnouncementsController.ts | |||
@@ -1,20 +1,16 @@ | |||
1 | import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | 1 | import type { HttpContext } from '@adonisjs/core/http' |
2 | import Application from '@ioc:Adonis/Core/Application'; | 2 | import { app } from '@adonisjs/core/services/app' |
3 | import path from 'node:path'; | 3 | import path from 'node:path' |
4 | import fs from 'fs-extra'; | 4 | import fs from 'fs-extra' |
5 | 5 | ||
6 | export default class AnnouncementsController { | 6 | export default class AnnouncementsController { |
7 | public async show({ response, params }: HttpContextContract) { | 7 | public async show({ response, params }: HttpContext) { |
8 | const announcement = path.join( | 8 | const announcement = path.join(app.resourcesPath(), 'announcements', `${params.version}.json`) |
9 | Application.resourcesPath(), | ||
10 | 'announcements', | ||
11 | `${params.version}.json`, | ||
12 | ); | ||
13 | 9 | ||
14 | if (await fs.pathExists(announcement)) { | 10 | if (await fs.pathExists(announcement)) { |
15 | return response.download(announcement); | 11 | return response.download(announcement) |
16 | } | 12 | } |
17 | 13 | ||
18 | return response.status(404).send('No announcement found.'); | 14 | return response.status(404).send('No announcement found.') |
19 | } | 15 | } |
20 | } | 16 | } |