Skip to content

Commit

Permalink
breaking(api): update deps and fixes #84
Browse files Browse the repository at this point in the history
  • Loading branch information
dalisoft committed Mar 23, 2020
1 parent f5a3cef commit 2dadb46
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion examples/error-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app.setErrorHandler((err, req, res) => {
res.end('error was handled: ' + err.message);
});

app.setNotFoundHandler((res) => {
app.setNotFoundHandler((req, res) => {
res.end('you accessing to missing route??');
});

Expand Down
2 changes: 1 addition & 1 deletion examples/error-status-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ app.get('/500', (req, res) => {
res.end('505');
});

app.listen(4000);
app.listen(4000);
6 changes: 3 additions & 3 deletions examples/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const strategy = new LocalStrategy(
usernameField: 'username',
passwordField: 'password'
},
function(req, username, password, done) {
function (req, username, password, done) {
if (password !== '12345678') {
return done(null, false);
}
Expand All @@ -45,11 +45,11 @@ const strategy = new LocalStrategy(

// Configuration
passport.use(strategy);
passport.serializeUser(function(user, done) {
passport.serializeUser(function (user, done) {
done(null, user);
});

passport.deserializeUser(function(user, done) {
passport.deserializeUser(function (user, done) {
done(null, user);
});

Expand Down
2 changes: 1 addition & 1 deletion examples/upload-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ app.post('/', (req, res) => {
console.debug('files', req.files);
console.debug('body', req.body);

req.files.file.mv(path.join(__dirname, '/uploads/file.jpg'), function(err) {
req.files.file.mv(path.join(__dirname, '/uploads/file.jpg'), function (err) {
if (err) {
res.status(500);
return res.send(err);
Expand Down
4 changes: 2 additions & 2 deletions nanoexpress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ declare namespace nanoexpress {
): nanoexpressApp;
setNotFoundHandler(
notFoundHandlerCallback: (
res: HttpResponseBasic,
req: HttpRequestBasic
req: HttpRequestBasic,
res: HttpResponseBasic
) => HttpRequestBasic
): nanoexpressApp;
setValidationErrorHandler(
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nanoexpress",
"version": "1.1.18",
"version": "2.0.0",
"description": "Nano-framework for Node.js powered by uWebSockets.js",
"main": "build/nanoexpress.js",
"module": "src/nanoexpress.js",
Expand Down Expand Up @@ -55,8 +55,8 @@
"husky": "^4.0.2",
"jest": "^25.1.0",
"lint-staged": "^10.0.3",
"prettier": "^1.17.1",
"rollup": "^1.32.1",
"prettier": "^2.0.1",
"rollup": "^2.1.0",
"rollup-plugin-node-resolve": "^5.2.0"
},
"peerDependencies": {
Expand Down
5 changes: 1 addition & 4 deletions src/helpers/is-simple-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ const HttpRequestAdvancedProps = [
const AllowedMembers = ['req', 'res'];

const lineGoHandle = (string, handler) =>
string
.split('\n')
.map(handler)
.join('\n');
string.split('\n').map(handler).join('\n');

const isMalicius = (string) =>
!string.startsWith('async') && !string.startsWith('(re');
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/prepare-swagger-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default function swaggerDocsGenerator(
typeName === 'params'
? 'path'
: typeName === 'response'
? 'responses'
: typeName === 'body'
? 'requestBody'
: typeName;
? 'responses'
: typeName === 'body'
? 'requestBody'
: typeName;

if (swaggerDef.paths[path] === undefined) {
swaggerDef.paths[path] = {};
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/send-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const compressions = {
};
const bytes = 'bytes=';

export default async function(
export default async function (
path,
{
lastModified = true,
Expand Down
16 changes: 8 additions & 8 deletions src/helpers/sifrr-server/stream-to-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ export default function stob(stream) {

stream.on('end', () => {
switch (buffers.length) {
case 0:
resolve(Buffer.allocUnsafe(0));
break;
case 1:
resolve(buffers[0]);
break;
default:
resolve(Buffer.concat(buffers));
case 0:
resolve(Buffer.allocUnsafe(0));
break;
case 1:
resolve(buffers[0]);
break;
default:
resolve(Buffer.concat(buffers));
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default (path = '/*', fns, config, ajv, method, app) => {
if (error) {
return config._notFoundHandler
? config._notFoundHandler
: (res) =>
: (req, res) =>
res.end(
'{"middleware_type":"sync","error":"The route handler not found"}'
);
Expand Down
10 changes: 5 additions & 5 deletions src/nanoexpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ const nanoexpress = (options = {}) => {

// Set not found handler
if (!_app.anyApplied) {
app.get(
_app.get(
'/*',
config._notFoundHandler ||
((res) => {
((req, res) => {
res.end(
'{"middleware_type":"sync","error":"The route handler not found"}'
);
Expand All @@ -149,9 +149,9 @@ const nanoexpress = (options = {}) => {
if (token) {
_app._instance = token;
logger.log(
`[Server]: started successfully at [${
config.host
}:${port}] in [${Date.now() - time}ms]`
`[Server]: started successfully at [${config.host}:${port}] in [${
Date.now() - time
}ms]`
);
resolve(_app);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/proto/http/response-chunks/modify-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default function modifyEnd() {
if (!this._modifiedEnd) {
const _oldEnd = this.end;

this.end = function(chunk, encoding) {
this.end = function (chunk, encoding) {
// eslint-disable-next-line prefer-const
let { _headers, statusCode } = this;

Expand Down
2 changes: 1 addition & 1 deletion tests/optional-functions/ip-address.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import nanoexpress from '../../src/nanoexpress';
import http from 'http';

describe('bind to specific host', function() {
describe('bind to specific host', function () {
let app = null;

beforeAll(() => {
Expand Down

0 comments on commit 2dadb46

Please sign in to comment.