stop saving url in paste
This commit is contained in:
parent
a4156f82d8
commit
29ed8c1073
|
@ -137,7 +137,6 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
id,
|
id,
|
||||||
url: `${env.SITE_URL}/${id}.${highlight}`,
|
|
||||||
highlight,
|
highlight,
|
||||||
encrypted: !!password,
|
encrypted: !!password,
|
||||||
contents: pasteContents,
|
contents: pasteContents,
|
||||||
|
@ -148,15 +147,20 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
const pastes = await Mongo.getNamedCollection("pastes");
|
const pastes = await Mongo.getNamedCollection("pastes");
|
||||||
const res = await pastes.insertOne(data);
|
const res = await pastes.insertOne(data);
|
||||||
|
|
||||||
|
const url = `${env.SITE_URL}/${id}.${highlight}`;
|
||||||
|
|
||||||
if (!res.acknowledged) {
|
if (!res.acknowledged) {
|
||||||
throw error(500, 'Failed to create paste');
|
throw error(500, 'Failed to create paste');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (raw) {
|
if (raw) {
|
||||||
return json(data, {
|
return json({
|
||||||
|
...data,
|
||||||
|
url,
|
||||||
|
}, {
|
||||||
status: 201,
|
status: 201,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return text(data.url + '\n');
|
return text(url + '\n');
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue