feat(api): add issues and version endpoints

This commit is contained in:
wanhose 2024-10-09 01:52:18 +02:00
parent c1d2a3d93a
commit 46aefd4688

View File

@ -0,0 +1,27 @@
import { FastifyInstance, RouteShorthandOptions } from 'fastify';
import fetch from 'node-fetch';
import environment from 'services/environment';
export default (server: FastifyInstance, _options: RouteShorthandOptions, done: () => void) => {
server.get('/version/', async (_request, reply) => {
try {
const options = { headers: { 'Cache-Control': 'no-cache' } };
const url = `${environment.github.files}/packages/browser-extension/src/manifest.json`;
const { version } = await (await fetch(url, options)).json();
reply.send({
data: {
version,
},
success: true,
});
} catch (error) {
reply.send({
errors: [error.message],
success: false,
});
}
});
done();
};