Sunday, February 12, 2017

Expressjs with Compound

First steps: install compound and generate app

  1. if not already installed, install nodejs (v 0.8.0+) - http://nodejs.org/download/. If you have node installed you can test your version with: node --version
  2. install compound using npm. Doing this globally enables the compound command line tool. You might need to sudo.
    npm install compound -g or sudo npm install compound -g
  3. generate the todo-list app using the compound command line. This creates an application with the default compoundjs structure.
    compound init todo-list-app
  4. install the dependencies (see package.json for default dependencies. They will be downloaded to the node_modules dir)
    cd todo-list-app && npm install
Now that we have the initial compound app structure, we can run your new compoundjs application.
Let's run the command node . and then open http://localhost:3000/ in a browser.
NOTE the node . command is simple way to run the application in the current directory. You also can run node server.js or coffee server.coffee or even compound server. the result will be the same, we will learn the differences later.
After opening localhost:3000 in a browser we will see a welcome page with some links and debug info (this appears after you click on the corresponding link). This is a static file located ./public/index.html. Everything in the ./public dir will be available to your app as static content so client-side javascripts and stylesheets should be saved here.
NOTE some javascript files and stylesheets may be generated from coffee or sass / less / stylus. Sources for these files are located at ./app/assets and compiled automatically using co-assets-compiler extension module.
https://github.com/compoundjs/guides/blob/master/basics/crash-course.md

1. C:\Node4Express>npm install compound -g
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install th
e latest version of pug instead of jade
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher
 to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@2.0.3: graceful-fs v3.0.0 and before will fail o
n node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible
. Use 'npm ls graceful-fs' to find it in the tree.
C:\Users\User\AppData\Roaming\npm\compound -> C:\Users\User\AppData\Roaming\npm\
node_modules\compound\bin\compound.js
C:\Users\User\AppData\Roaming\npm\rw -> C:\Users\User\AppData\Roaming\npm\node_m
odules\compound\bin\compound.js
C:\Users\User\AppData\Roaming\npm
`-- compound@1.2.4
  +-- coffee-script@1.7.1
  | `-- mkdirp@0.3.5
  +-- ejs-ext@0.1.4-5
  +-- inflection@1.2.7
  +-- jade-ext@0.0.7
  +-- kontroller@0.0.15
  | `-- mocha@1.17.1
  |   +-- commander@2.0.0
  |   +-- debug@2.6.1
  |   | `-- ms@0.7.2
  |   +-- diff@1.0.7
  |   +-- glob@3.2.3
  |   | +-- graceful-fs@2.0.3
  |   | +-- inherits@2.0.3
  |   | `-- minimatch@0.2.14
  |   |   +-- lru-cache@2.7.3
  |   |   `-- sigmund@1.0.1
  |   +-- growl@1.7.0
  |   `-- jade@0.26.3
  |     +-- commander@0.6.1
  |     `-- mkdirp@0.3.0
  +-- railway-routes@0.0.12
  `-- yaml-js@0.1.4

C:\Node4Express>node --version
v6.9.5

2. C:\Node4Express>compound init todo-list -app
create  todo-list
create  todo-list\app\
create  todo-list\app\assets\
create  todo-list\app\assets\coffeescripts\
create  todo-list\app\assets\stylesheets\
create  todo-list\app\models\
create  todo-list\app\controllers\
create  todo-list\app\helpers\
create  todo-list\app\tools\
create  todo-list\app\views\
create  todo-list\app\views\layouts\
create  todo-list\db\
create  todo-list\db\seeds\
create  todo-list\db\seeds\development\
create  todo-list\log\
create  todo-list\public\
create  todo-list\public\images
create  todo-list\public\stylesheets\
create  todo-list\public\javascripts\
create  todo-list\node_modules\
create  todo-list\config\
create  todo-list\config\locales\
create  todo-list\config\initializers\
create  todo-list\config\environments\
create  todo-list\app\assets\coffeescripts\application.coffee
create  todo-list\app\assets\stylesheets\application.styl
create  todo-list\app\tools\database.js
create  todo-list\config\environment.js
create  todo-list\config\environments\development.js
create  todo-list\config\environments\production.js
create  todo-list\config\environments\test.js
create  todo-list\config\routes.js
create  todo-list\config\autoload.js
create  todo-list\db\schema.js
create  todo-list\public\index.html
create  todo-list\public\stylesheets\bootstrap.css
create  todo-list\public\stylesheets\bootstrap-responsive.css
create  todo-list\public\images\glyphicons-halflings-white.png
create  todo-list\public\images\glyphicons-halflings.png
create  todo-list\public\images\compound.png
create  todo-list\public\javascripts\rails.js
create  todo-list\public\javascripts\bootstrap.js
create  todo-list\public\javascripts\application.js
create  todo-list\public\favicon.ico
create  todo-list\Procfile
create  todo-list\README.md
create  todo-list\package.json
create  todo-list\server.js
create  todo-list\.gitignore
create  todo-list\config\database.js
create  todo-list\app\views\layouts\application_layout.ejs
create  todo-list\app\controllers\application_controller.js

install the dependencies (see package.json for default dependencies. They will be downloaded to the node_modules dir)
cd todo-list-app && npm install
.. long long list of structures

Let's run the command node . and then open http://localhost:3000/ in a browser.
NOTE the node . command is simple way to run the application in the current directory. You also can run node server.js or coffee server.coffee or even compound server. the result will be the same, we will learn the differences later.
C:\Node4Express\todo-list>node .
express deprecated app.configure: Check app.get('env') in an if statement config
\environment.js:6:9
connect deprecated methodOverride: use method-override npm module instead config
\environment.js:16:25
express deprecated app.configure: Check app.get('env') in an if statement config
\environments\development.js:6:9
(node:8156) DeprecationWarning: sys is deprecated. Use util instead.
Compound server listening on 0.0.0.0:3000 within development environment

No comments:

Post a Comment