Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,883 additions
and
332 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
node_modules | ||
|
||
.DS_Store | ||
.env | ||
docker-compose.override.yml | ||
*.log | ||
.DS_Store | ||
.nyc_output | ||
.yarn* | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,7 @@ test | |
|
||
.DS_Store | ||
.env | ||
.jshintrc | ||
.jshintignore | ||
.eslintrc.js | ||
.travis.yml | ||
*.log | ||
yarn.lock | ||
yarn* |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,19 @@ | ||
require('./lib/seed')() | ||
const { compose, prop } = require('ramda') | ||
const http = require('http') | ||
|
||
const { | ||
json, logger, methods, mount, parseJson, | ||
redirect, routes, static: renderStatic | ||
} = require('..') | ||
|
||
const { | ||
createUser, | ||
fetchUser, | ||
fetchUsers, | ||
updateUser | ||
} = require('./api/users') | ||
const { compose } = require('ramda') | ||
const future = require('redux-future').default | ||
const http = require('http') | ||
const { mount, parseJson } = require('..') | ||
|
||
const { home } = require('./api/pages') | ||
const logger = require('./lib/logger') | ||
const routes = require('./routes') | ||
|
||
const port = process.env.PORT || 3000 | ||
|
||
const listening = err => | ||
err ? console.error(err) : console.info(`Listening on port: ${port}`) | ||
|
||
const endpoints = routes({ | ||
'/': methods({ | ||
GET: home | ||
}), | ||
|
||
'/cookies': compose(json, prop('cookies')), | ||
|
||
'/public/:path+': renderStatic({ root: 'demo/public' }), | ||
|
||
'/users': methods({ | ||
GET: fetchUsers, | ||
POST: createUser | ||
}), | ||
|
||
'/users/:id': methods({ | ||
GET: fetchUser, | ||
PATCH: updateUser, | ||
PUT: updateUser | ||
}), | ||
|
||
'/error': () => { throw new Error('this code is broken') }, | ||
const app = compose(routes, parseJson) | ||
|
||
'/old-users': () => redirect('/users') | ||
}) | ||
const middleware = [ future ] | ||
|
||
const app = compose(endpoints, parseJson) | ||
const opts = { errLogger: logger, logger } | ||
const server = http.createServer(mount({ app, logger, middleware })) | ||
|
||
http.createServer(mount(app, opts)).listen(port, listening) | ||
if (require.main === module) server.listen(port, logger) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const { compose, dissocPath } = require('ramda') | ||
const { logger } = require('../..') | ||
|
||
module.exports = compose(logger, dissocPath(['req', 'headers'])) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { always, compose, prop } = require('ramda') | ||
const { json, methods, routes, send, serve } = require('../..') | ||
|
||
const pages = require('./pages') | ||
const users = require('./users') | ||
|
||
const error = () => { | ||
throw new Error('this code is broken') | ||
} | ||
|
||
module.exports = routes({ | ||
'/api/old-users': methods({ | ||
GET: users.oldUsers | ||
}), | ||
|
||
'/api/users': methods({ | ||
GET: users.fetchUsers, | ||
POST: users.createUser | ||
}), | ||
|
||
'/api/users/:id': methods({ | ||
GET: users.fetchUser, | ||
PATCH: users.updateUser, | ||
PUT: users.updateUser | ||
}), | ||
|
||
'/cookies': compose(json, prop('cookies')), | ||
|
||
'/error': error, | ||
|
||
'/health': always(send()), | ||
|
||
'/public/:path+': serve({ root: 'demo/public' }), | ||
|
||
'/': methods({ | ||
GET: pages.home | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
require('pug/register') | ||
const { Async } = require('crocks') | ||
const { objOf } = require('ramda') | ||
const { html } = require('../..') | ||
|
||
const db = require('../lib/db')('users') | ||
const home = require('../views/home') | ||
|
||
const where = Async.fromPromise(db.where) | ||
|
||
exports.home = () => | ||
db.where({ keys: false }) | ||
.then(objOf('users')) | ||
.then(home) | ||
.then(html) | ||
where({ keys: false }) | ||
.map(objOf('users')) | ||
.map(home) | ||
.map(html) |
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
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
Oops, something went wrong.