Skip to content

Instantly share code, notes, and snippets.

View N8BAUER's full-sized avatar
🕯️
No better place than github to work on my commitment issues

Nate Bauer N8BAUER

🕯️
No better place than github to work on my commitment issues
  • Denver, CO
View GitHub Profile
//no salt yo
const passwordHash = require('password-hash');
module.exports = function hashString(str, callback) {
const hashed = passwordHash.generate(str)
callback(null, hashed)
}
//salted hash
//TO INSTALL: npm install express cors body-parser morgan monk
const http = require('http')
const express = require('express')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const app = module.exports = express()
const server = http.createServer(app)
const port = parseInt(process.env.PORT || 3000)
app.use(bodyParser.json())
//TO INSTALL: npm install express cors body-parser morgan monk
const http = require('http')
const express = require('express')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const app = module.exports = express()
const server = http.createServer(app)
const port = parseInt(process.env.PORT || 3000)
app.use(bodyParser.json())
//TO INSTALL: npm install express cors body-parser morgan monk
const http = require('http')
const express = require('express')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const app = module.exports = express()
const server = http.createServer(app)
const port = parseInt(process.env.PORT || 3000)
app.use(bodyParser.json())
//TO INSTALL: npm install express cors body-parser morgan monk
const http = require('http')
const express = require('express')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const app = module.exports = express()
const server = http.createServer(app)
const port = parseInt(process.env.PORT || 3000)
app.use(bodyParser.json())
const router = module.exports = require('express').Router
const hash = require("../hash")
const users = [] //in=memory 'dummy data source'
// Standard CRUD routes:
router.get('/', getAll)
router.get('/:id', getOne)
router.post('/', create)
router.put('/:id', update)
router.delete('/:id', remove)
@N8BAUER
N8BAUER / rest-mongodb-with-monk.js
Created October 16, 2017 17:17 — forked from justsml/rest-arrays-template.js
REST Route Templates w/ Data Layer Code Included
// CHECK `TODO` NOTICES BELOW FILE!!!
// TODO: Update Move data layer out of here
const connString = 'user:pass@localhost:port/mydb' // TODO: Add env vars
const db = require('monk')(connString)
// TODO: move following to something like: app/db/items.js:
const items = db.get('items')
items.index('name first last email')
// incl: module.exports = items