fix: more types for API

This commit is contained in:
Andras Bacsai
2022-07-14 12:47:26 +00:00
parent ce31146a9c
commit 90597389c9
40 changed files with 722 additions and 316 deletions

View File

@@ -1,21 +1,22 @@
import { FastifyPluginAsync } from 'fastify';
import { checkGitLabOAuthID, deleteSource, getSource, listSources, saveGitHubSource, saveGitLabSource, saveSource } from './handlers';
import type { OnlyId } from '../../../../types';
import type { CheckGitLabOAuthId, SaveGitHubSource, SaveGitLabSource } from './types';
const root: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
fastify.addHook('onRequest', async (request, reply) => {
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
fastify.addHook('onRequest', async (request) => {
return await request.jwtVerify()
})
fastify.get('/', async (request) => await listSources(request));
fastify.get('/:id', async (request) => await getSource(request));
fastify.get<OnlyId>('/:id', async (request) => await getSource(request));
fastify.post('/:id', async (request, reply) => await saveSource(request, reply));
fastify.delete('/:id', async (request) => await deleteSource(request));
fastify.post('/:id/check', async (request) => await checkGitLabOAuthID(request));
fastify.post('/:id/github', async (request, reply) => await saveGitHubSource(request, reply));
fastify.post('/:id/gitlab', async (request, reply) => await saveGitLabSource(request, reply));
fastify.post<CheckGitLabOAuthId>('/:id/check', async (request) => await checkGitLabOAuthID(request));
fastify.post<SaveGitHubSource>('/:id/github', async (request) => await saveGitHubSource(request));
fastify.post<SaveGitLabSource>('/:id/gitlab', async (request) => await saveGitLabSource(request));
};
export default root;