Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Fluture 12 #27

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions example/actions/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ const Future = require ('fluture');
const fs = require ('fs');
const path = require ('path');

const access = Future.encaseN2 (fs.access);
const access = x => y => Future.node (c => fs.access (x, y, c));

module.exports = req => Future.go (function* () {
if (!req.query.file) {
yield Future.reject (
new Error ('You need to provide a query named "file"')
);
}

module.exports = req => Future.do (function* () {
const file = path.resolve (__dirname, '..', path.basename (req.query.file));

if (path.extname (req.query.file) !== '.jpeg') {
yield Future.reject (new Error ('You can only load JPEGs'));
}

yield (access (file, fs.constants.R_OK)).mapRej (
_ => new Error ('No read access to the requested file')
);
yield Future.mapRej
(_ => new Error ('No read access to the requested file'))
(access (file) (fs.constants.R_OK));

return Stream (200,
path.extname (req.query.file),
Expand Down
2 changes: 1 addition & 1 deletion example/actions/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
const {Next} = require ('../..');
const Future = require ('fluture');

module.exports = (req, locals) => Future.of (Next (Object.assign ({
module.exports = (req, locals) => Future.resolve (Next (Object.assign ({
session: {id: req.headers['x-authenticated-user']},
}, locals)));
2 changes: 1 addition & 1 deletion example/actions/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
const {Json} = require ('../..');
const Future = require ('fluture');

module.exports = (req, locals) => Future.of (Json (200, {
module.exports = (req, locals) => Future.resolve (Json (200, {
welcome: locals.session.id ? `user ${locals.session.id}` : 'stranger',
}));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"daggy": "^1.2.0"
},
"peerDependencies": {
"fluture": ">=6.0.0 <13.0.0"
"fluture": ">=12.0.0 <13.0.0"
},
"devDependencies": {
"codecov": "^3.0.0",
Expand Down