8.0.0 #3
27
packages/api/src/routes/v5/version.ts
Normal file
27
packages/api/src/routes/v5/version.ts
Normal 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();
|
||||
};
|
Loading…
Reference in New Issue
Block a user