finalized project

This commit is contained in:
didier amyot committed 2023-06-13 14:05:09 -04:00
1 parent b8b3e348e8
commit 4b87e9d20c
15 files changed
+1027 -4

No files matched your search

+2
View File
@@ -10,6 +10,8 @@ export {
TextLineStream,
} from 'https://deno.land/std@0.191.0/streams/mod.ts';
export {Status} from "https://deno.land/std@0.191.0/http/http_status.ts";
export { oakCors } from 'https://deno.land/x/cors/mod.ts';
// oak
export { Application, Context, Router } from 'https://deno.land/x/oak/mod.ts';
+2
View File
@@ -3,6 +3,7 @@ import { FileMetaData, FileService } from './services/mod.ts';
import { readerFromStreamReader } from './deps.ts';
import { asyncIterableToArray } from './utils.ts';
import { Vector3D, WaveFrontService } from './services/interfaces.ts';
import { bigAndUglySwagger } from "./stagger.ts";
type Handler = (ctx: Context) => void;
@@ -161,6 +162,7 @@ function deleteFileHandlerFactory(fileService: FileService): Handler {
}
export function buildAPI(router: Router, fileService: FileService, waveFrontService: WaveFrontService): Router {
router.get('/swagger', (ctx) => ctx.response.body = bigAndUglySwagger);
router.get('/files', listFileHandlerFactory(fileService));
router.get('/files/:fileId', getFileHandlerFactory(fileService));
router.delete('/files/:fileId', deleteFileHandlerFactory(fileService));
+2 -1
View File
@@ -1,4 +1,4 @@
import { Application, Router } from './deps.ts';
import { Application, Router, oakCors } from './deps.ts';
import { buildAPI } from './restapi.ts';
import { DenoKVFileService } from './services/mod.ts';
import { WaveFrontServiceImpl } from './services/wavefrontService.ts';
@@ -10,6 +10,7 @@ async function main() {
const waveFrontService = new WaveFrontServiceImpl();
const router = new Router({ prefix: '/v1' });
app.use(oakCors({ origin: /^.+localhost:7766$/ }));
app.use(
buildAPI(router, fileService, waveFrontService).routes(),
);
+10
View File
@@ -0,0 +1,10 @@
export const bigAndUglySwagger = `
openapi: 3.0.3
info:
title: Test task
description: |-
This should be swagger documentation.
version: 1.0.11
paths: {}
`