Skip to content

Instantly share code, notes, and snippets.

@runvnc
Created October 26, 2015 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runvnc/45c827c15f44fb778a65 to your computer and use it in GitHub Desktop.
Save runvnc/45c827c15f44fb778a65 to your computer and use it in GitHub Desktop.
import level from 'level';
const db = level('links');
import {inspect} from 'util';
db.createReadStream()
.on('data', data => {
console.log(`${data.key}=${inspect(data.value)}`);
});
// server.js
import link from './link';
import shortrest from 'shortrest';
const web = shortrest(8099), user = 'test';
web.post('/link', async (req, res) => {
try {
const {descr, URL} = req.params;
res.json(await link.create({descr, URL, user}));
} catch (e) {
res.json({error: e});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment