I imagine (though I'm not sure) that Sapper supports all of the request types that express supports, but trying to export a DELETE handler currently won't work because delete is a reserved keyword, so export function delete(){} won't work.
Is there a clever workaround to trick js into letting me use delete? If not, could we add one to Sapper?
I thought maybe webpack harmony magic would let this work, but it doesn't seem to:
export default {
delete(req, res) {
console.log('delete');
}
};
Thanks! And great work as always, Sapper is fun.
Wouldn't you need to do this?
export function delete(req, res) {
//
}
In CJS terms, your example would be available as exports.default.delete when you want exports.delete.
That's right @lukeed, but what you have written throws Module parse failed: Unexpected token because delete is a reserved keyword.
I think most people handle this by using _delete, del, remove or destroy. Other more colorful options include annihilate, smash, crush.
good point! I think del is probably the best option here:
export function del(req, res) {
// ...
}
Any objections?
Seems like the best option to me!
Released 0.4 with export function del(...){...} support thanks to @EmilTholin
Most helpful comment
Released 0.4 with
export function del(...){...}support thanks to @EmilTholin