最近仕事ではNode.jsでサーバサイドなプログラミングばかりしているのですが、人に教える機会が凄く多くなってきました。 他の言語やっている人が、1から(人によってはJavaScriptから) Node.jsをやってみたい!という人がちょくちょく僕を訪ねてくれます。
最近仕事ではNode.jsでサーバサイドなプログラミングばかりしているのですが、人に教える機会が凄く多くなってきました。 他の言語やっている人が、1から(人によってはJavaScriptから) Node.jsをやってみたい!という人がちょくちょく僕を訪ねてくれます。
最近流行の node.js と、Webアプリ用のミドルウェア Express で Web アプリケーションを書いています。 ユーザー認証の機能が欲しかったので、 Passport というユーザー認証用のミドルウェアを使ってみる事にしました。 同じような機能を実現するミドルウェアには everyauthがあります。が、 ログイン画面などへのルーティングの仕方を、 express のルーティングと一緒に書けなくて気持ち悪いので、今回は見送ることにしました。 Passport の特徴はこんな感じ。らしい。 Strategy というオブジェクトを切り替えることで、様々な認証方法に対応 Local(よくある、ユーザー名とパスワードでの認証) Twitter Facebook とかとか。140以上あるらしいです。 認証成功時、失敗時の処理の書き方が簡単 アプリケーションのルーティングの上書きをしない
Get Your Large Dynamic JavaScript Website, Crawled, Indexed and Found
先月、HTML5など勉強会に参加した時、雑談タイムで 「 yeoman を使ってバックエンドの開発とかできないですか? 」 という内容に対して、フォローとして 「 gruntでリバースプロキシ使えますよ 」 っていうお話をした。 そのまま記事に書かずじまいで申し訳ないなーと思っていたら、@bathtimefish さんがブログをアップされていた。 その記事、 YeomanでフロントエンドとREST APIサーバーを同時に開発する方法 でリバースプロキシを使った手法が挙がっていたのですが、gruntのモジュールを使うともう少し楽ができそう。 私は、easymock を知らなかったですし、やはりyeoman 使ってる人が周りにあまりおらず、前回の勉強会は非常に勉強になったので、ここは一つ御礼の意味を込めてブログを書こうと思います。 ということで、yeoman(grunt) を使ったバックエンド
なんだこのプレゼンは? と思ったプレゼンをネット上で見かけた。 Build Warsへのリンク JavaScriptのプロダクトをうまい具合にビルドするためのツール、 Gruntとglupを比較したプレゼンだ。 gifアニメが多用されてるし、オサレでカッコイイ。 何使ってこのプレゼン作ってるんだ!?と思って調べてみたら、 このプレゼンの作者が自分で作っていた。 bespoke.jsというアプリだった。 bespoke.jsというプレゼンアプリを早速使ってみたい。 セットアップや、プレゼンのスケルトン作成って めんどくさいのかなと思ったんだけど、yeomanを利用して テンプレを作成する形になってて、 プレゼン作成準備に必要な手間は少ししかなかった。 bespoke.jsを使うまで bespoke.jsをセットアップするのに必要なツールは以下の通り。 node.js yeoman Mac O
passport.authenticate('facebook');('google');('apple');('microsoft');('twitter');('linkedin');('github');('openid'); Passport is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more.
2014/02/01 -- 結論が出たようなので、追記。 あと下記の指摘をいただきまして、少し修正しました。 @yosuke_furukawa 「自分の意見としては、basename...という案だ」ていうのはちょっと違うと思います。最初に出した条件反射的案(basename案)があんまよくなくて、もう一つの妥協案としてヤバげなものを除外してデフォルト有効するってのはどう?って意味かと。— MIURA Toru (@buri17) January 31, 2014 - ここ最近、Node.jsのgithubリポジトリ上でharmonyオプションに関して議論されてて、 この辺り勘違いしている人も多そうなのでこの際まとめようかと。 Node.js 0.12 では yield が使えるのでコールバック地獄にサヨナラできる話 - てっく煮ブログ 去年の6月に公開された記事ですが、この記事を読んでv
Koaのmiddleware作成方法 さて、先日 koa入門 という入門記事を書いてみました。今回はそれにともなってKoaのミドルウェアの作り方を中心に説明します。 また、 koa-livereload というKoaのミドルウェアも公開してみました。それについても説明します。 Expressのミドルウェアの書き方: Expressのミドルウェアの書き方をまずはおさらい。 app.use(function (req, res, next){ // requestとresponseとnextを持つ関数を受け取る。 // 適当に/_chkに来たら、OKを返すミドルウェアを作る。 if (req.url === "/_chk") { console.log("OK"); res.send(200, "OK"); } // next()を呼び出すと次のミドルウェアを呼ぶ。 next(); }); K
2014年03月06日18:00 カテゴリTipsLightweight Languages llevalに久しぶりに手を入れた サーバサイドJavaScript Node.js入門 OSバージョンを上げたついでに、llevalにも手を入れたので変更点など。 lleval - run codes from your browser node.js はじめました (Java|ECMA)Scriptの実装をSpiderMonkeyからnode.jsに変更しました。 これによって、今まで標準出力するメソッドは print() ではなく console.log() になります。 for (var i = 1; i <= 30; i++) console.log ( i % 15 ? i % 5 ? i % 3 ? i : 'Fizz' : 'Buzz' : 'FizzBuzz' ); es6もサポ
image/svg+xmlMetalsmith logoKevin Van LierdeIan Storm TaylorAn extremely simple, pluggable static site generator for NodeJS. Get Started ConvenientMetalsmith works with all the tools and data formats you already know and use: NodeJS, npm, markdown, json, yaml and the templating language of your choice. SimpleMetalsmith translates a directory tree to plain Javascript objects that you can manipulate
We’ve had three minor releases since the last blog post so let’s see what has changed! Formatted JSON responsesIn 0.4.0 we removed the app.jsonSpaces setting — a setting used to specify the formatting of a JSON response. The default values were to pretty-print in development, and compress JSON in other environments. The main issue here is that this can cause unexpected results when running tests i
JavaScript のオブジェクト作成においてクラス定義で継承を実装する方法はいくつかあります。 正しい継承はどうあるべきか、基本から検証しながら考えてみたいと思います。 ※正しくクラス定義がエコ楽にできる様に追加記事書きました。 [JavaScript] getter/setterも使えるエコ楽なクラス定義 - もちろん継承も - private変数も 一番簡単なオブジェクトの作成方法 典型的な JavaScript のオブジェクトを簡単に作成してみて、それらを確認してみましょう。 var obj1 = {x: 12, y: "ab"}; var obj2 = new Object; // または new Object() obj2.x = 34; obj2.y = "cd"; // obj < Object var obj3 = [12, "ab"]; var obj4 = new
なんでMongoDBでセッション管理するのか Node.js + Express (Connect) で標準で提供されている MemoryStore でセッション管理を行うとメモリ上での管理になるため node が落ちるとセッションデータが消えることになりセッションの永続化ができませんし、動作確認もソースの確認も行っていませんが、production で起動した際に出力されるメッセージ(https://github.com/senchalabs/connect/blob/master/lib/middleware/session.js#L199)に Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and will n
InfoQ 2011.10.11のエントリ InfoQ: Node.js in Action: Interview and Book Excerpt 普段スピーカとかやらないTJ Holowaychukがざっくばらんな感じで面白い 24歳、オール独学、グラフィックデザイン畑出身、phpを最初に学んだのは不運、rubyなみに堅牢なスクレイピングツールをnodeにも欲しい、などなど 具体的に名指ししてないけど、pyjamasとかGWTのような「jsを書かずに済ませる、jsを生成してくれる」系の言語/DSLに色々意見があるらしく、一問一答にそのトピック何度も差し挟まれるんだけど、歯が立たない箇所が多し 追記:TJはCoffeescriptいらない派らしい Twitter / @tjholowaychuk: @jprichardson the latter ... 以下斜め読んだ内容 近刊の『No
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く