Skip to content

Instantly share code, notes, and snippets.

@jxpsert
Created July 13, 2022 21:18
Show Gist options
  • Select an option

  • Save jxpsert/e2c0ddad5be4c4bb718dff2dd8783f50 to your computer and use it in GitHub Desktop.

Select an option

Save jxpsert/e2c0ddad5be4c4bb718dff2dd8783f50 to your computer and use it in GitHub Desktop.
class Endpoint {
constructor(endpoint) {
this.endpoint = endpoint;
}
format(s = 404, m = "Not found", d = {}) {
const f = {
status: s,
message: m,
data: d,
};
return f;
}
get(req, res) {
res.statusCode = 404;
res.send(this.format());
}
post(req, res) {
res.statusCode = 404;
res.send(this.format());
}
put(req, res) {
res.statusCode = 404;
res.send(this.format());
}
delete(req, res) {
res.statusCode = 404;
res.send(this.format());
}
}
module.exports = Endpoint;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment