This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//no salt yo | |
const passwordHash = require('password-hash'); | |
module.exports = function hashString(str, callback) { | |
const hashed = passwordHash.generate(str) | |
callback(null, hashed) | |
} | |
//salted hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |