add code generation on frontend
This commit is contained in:
28
src/routes/api/list/[[vorgang]]/code/+server.js
Normal file
28
src/routes/api/list/[[vorgang]]/code/+server.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { client } from '$lib/minio';
|
||||
import { Readable } from 'stream';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET({ params }) {
|
||||
const prefix = params.vorgang ? `${params.vorgang}` : '';
|
||||
|
||||
const code_name = '__perm__';
|
||||
const obj_path = `${prefix}/${code_name}`;
|
||||
|
||||
let result = null;
|
||||
|
||||
try {
|
||||
result = await client.getObject('tatort', obj_path);
|
||||
} catch (error) {
|
||||
if (error.name == 'S3Error') {
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
return new Response(result, { status: 200 });
|
||||
} else {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user