Skip to content

Instantly share code, notes, and snippets.

View buckeyja's full-sized avatar

Leo Buckey buckeyja

View GitHub Profile
@mqp
mqp / express-basic.js
Created February 6, 2020 05:28
Simple Express error handling
const app = require('express')();
const fs = require('fs');
// Resolves with a list of the filenames in dir, or rejects if dir doesn't exist or if something else goes wrong.
function readFileNames(dir) {
return new Promise((resolve, reject) => {
fs.readdir(dir, (err, files) => {
if (err) {
reject(err);
} else {
@mqp
mqp / express-wrapper.js
Created February 6, 2020 05:27
Fancy Express error handling
const app = require('express')();
const fs = require('fs');
// Resolves with a list of the filenames in dir, or rejects if dir doesn't exist or if something else goes wrong.
function readFileNames(dir) {
  return new Promise((resolve, reject) => {
    fs.readdir(dir, (err, files) => {
      if (err) {
        reject(err);
      } else {