File tree 3 files changed +48
-0
lines changed
3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Learn a Module, Node.JS
2
+
3
+
4
+ A command line tool that when called, will generate a random module.
5
+ Built as a tool to expose myself to a module per day and familiarizing myself with great things happening in Node.JS.
6
+
7
+
8
+ ## LICENSE
9
+
10
+ MIT
Original file line number Diff line number Diff line change
1
+ // Module of the Day randomizer
2
+ var qs = require ( 'querystring' )
3
+ , http = require ( 'http' )
4
+ , npm = require ( 'npm' ) ;
5
+
6
+ // use API to search npm, randomizing the result I get each time.
7
+
8
+ var search = process . argv . slice ( 2 ) . join ( ' ' ) . trim ( ) ; // is pulling the id which is required from the Twitter API
9
+
10
+ if ( ! search . length ) {
11
+ return console . log ( '\n Usage: node tweets <search term>\n' ) ;
12
+ }
13
+
14
+ console . log ( '\n searching for: \033[96m' + search + '\033[39m\n' ) ;
15
+
16
+ http . request ( {
17
+ host : 'search.twitter.com'
18
+ , path : '/search.json?' + qs . stringify ( { q :search } )
19
+ } , function ( res ) {
20
+ var body = '' ;
21
+ res . setEncoding ( 'utf8' ) ;
22
+ res . on ( 'data' , function ( chunk ) {
23
+ body += chunk ;
24
+ } ) ;
25
+ res . on ( 'end' , function ( ) {
26
+ var obj = JSON . parse ( body )
27
+ obj . results . forEach ( function ( tweet ) {
28
+ console . log ( ' \033[90m' + tweet . text + '\033[39m' ) ;
29
+ console . log ( ' \033[94m' + tweet . from_user + '\033[39m' ) ;
30
+ console . log ( '--' ) ;
31
+ } )
32
+ } )
33
+ } ) . end ( ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " learn_a_module"
3
+ , "description" : " Generates a random module of the day from the command line"
4
+ , "version" : " 0.0.1"
5
+ }
You can’t perform that action at this time.
0 commit comments