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

Next Version #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 12 additions & 8 deletions examples/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const debug = require('debug')('baiji:examples:express');

// Handle all uncaughtException avoid node instance crashing
process.on('uncaughtException', function(e) {
debug('uncaughtException', e, e.stack);
// eslint-disable-next-line
console.log('uncaughtException', e, e.stack);
});

// Article Controller
Expand All @@ -31,10 +32,10 @@ ArticlesCtrl.after('index', function(ctx, next) {

ArticlesCtrl.define('index', {
description: 'fetch article list',
params: [
{ name: 'q', type: 'string', description: 'keyword used for searching articles' },
{ name: 'ids', type: ['number'], description: 'article ids' }
],
params: {
q: { type: 'string', description: 'keyword used for searching articles' },
ids: { type: ['number'], description: 'article ids' }
},
route: { verb: 'get', path: '/' }
}, function(ctx, next) {
debug('method executed', ctx.actionName);
Expand All @@ -44,12 +45,15 @@ ArticlesCtrl.define('index', {

ArticlesCtrl.define('show', {
description: 'fetch article detail',
params: [
{ name: 'id', type: 'number', description: 'article id' }
],
params: {
id: { type: 'number', description: 'article id' }
},
route: { verb: 'get', path: '/:id' }
}, function(ctx, next) {
debug('method executed', ctx.actionName);
console.log({
id: 1
});
ctx.respond({
id: ctx.args.id,
title: 'baiji usage post',
Expand Down
Loading