-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { FastifyPluginCallback } from 'fastify'; | ||
import fp from 'fastify-plugin'; | ||
|
||
import { MetaObject } from '@imports/model/MetaObject'; | ||
import { logger } from '@imports/utils/logger'; | ||
|
||
const translationApi: FastifyPluginCallback = async fastify => { | ||
fastify.get<{ Querystring: { asImage?: string } }>('/api/info/logo', async (req, reply) => { | ||
const asImage = req.query.asImage != null; | ||
|
||
try { | ||
const { logoURL } = MetaObject.Namespace; | ||
if (logoURL == null) { | ||
return reply.status(404).send('Logo url not found'); | ||
} | ||
|
||
if (asImage) { | ||
const response = await fetch(logoURL); | ||
return reply.send(response.body); | ||
} | ||
|
||
return reply.send({ success: true, data: logoURL }); | ||
} catch (error) { | ||
logger.error(error, `Error getting logo url`); | ||
return reply.status(500).send('Internal server error'); | ||
} | ||
}); | ||
}; | ||
|
||
export default fp(translationApi); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters