mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-11 03:35:04 -05:00
25 lines
759 B
TypeScript
25 lines
759 B
TypeScript
import type { RequestHandler } from '@sveltejs/kit';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
export const POST: RequestHandler = async ({ request }) => {
|
|
const { respondentId, categories, notActionable, highlight } = await request.json();
|
|
const filePath = path.resolve('data/export.csv');
|
|
const csv = fs.readFileSync(filePath, 'utf-8');
|
|
const rows = csv.split('\n');
|
|
const headers = rows[0];
|
|
const data = rows.slice(1).map(row => {
|
|
const fields = row.split(',');
|
|
if (fields[0] === respondentId) {
|
|
return [
|
|
...fields.slice(0, 21),
|
|
categories.join('|'),
|
|
notActionable,
|
|
highlight
|
|
].join(',');
|
|
}
|
|
return row;
|
|
});
|
|
fs.writeFileSync(filePath, [headers, ...data].join('\n'));
|
|
return new Response(null, { status: 200 });
|
|
}; |