Node.js
NodeJS-Frameworks
Suche…
Webserver-Frameworks
ausdrücken
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
Koa
var koa = require('koa');
var app = koa();
app.use(function *(next){
var start = new Date;
yield next;
var ms = new Date - start;
console.log('%s %s - %s', this.method, this.url, ms);
});
app.use(function *(){
this.body = 'Hello World';
});
app.listen(3000);
Befehlszeilenschnittstellen-Frameworks
Commander.js
var program = require('commander');
program
.version('0.0.1')
program
.command('hi')
.description('initialize project configuration')
.action(function(){
console.log('Hi my Friend!!!');
});
program
.command('bye [name]')
.description('initialize project configuration')
.action(function(name){
console.log('Bye ' + name + '. It was good to see you!');
});
program
.command('*')
.action(function(env){
console.log('Enter a Valid command');
terminate(true);
});
program.parse(process.argv);
Vorpal.js
const vorpal = require('vorpal')();
vorpal
.command('foo', 'Outputs "bar".')
.action(function(args, callback) {
this.log('bar');
callback();
});
vorpal
.delimiter('myapp$')
.show();
Modified text is an extract of the original Stack Overflow Documentation
Lizenziert unter CC BY-SA 3.0
Nicht angeschlossen an Stack Overflow