node-express-mongoose-demo

A simple demo app using node and mongodb for beginners

Github星跟踪图

Build Status
Dependencies
Code Climate
Join Gitter Chat

Nodejs Express Mongoose Demo

This is a demo application illustrating various features used in everyday web development, with a fine touch of best practices. The demo app is a blog application where users can signup, create an article, delete an article and add comments etc.

Table of contents:

Boilerplate

Want to build something from scratch? use the boilerplate

Install

git clone git://github.com/madhums/node-express-mongoose-demo.git
npm install
cp .env.example .env
npm start

Then visit http://localhost:3000/

NOTE: Do not forget to set the twitter, google, linkedin and github CLIENT_IDs and SECRETs. In development env, you can set the env variables in .env and replace the values there. In production env, it is not safe to keep the ids and secrets in a file, so you need to set it up via commandline. If you are using heroku checkout how environment variables are set here.

Tests

npm test

Docker

You can also use docker for development. Make sure you run npm install on your host machine so that code linting and everything works fine.

npm i
cp .env.example .env

Start the services

docker-compose up -d

View the logs

docker-compose logs -f

In case you install a npm module while developing, it should also be installed within docker container, to do this first install the module you want with simple npm i module name, then run it within docker container

docker-compose exec node npm i

If you make any changes to the file, nodemon should automatically pick up and restart within docker (you can see this in the logs)

To run tests

docker-compose exec -e MONGODB_URL=mongodb://mongo:27017/noobjs_test node npm test

Note that we are overriding the environment variable set in .env file because we don't want our data erased by the tests.

Note: The difference between exec and run is that, exec executes the command within the running container and run will spin up a new container to run that command. So if you want to run only the tests without docker-compose up, you may do so by running docker-compose run -e MONGODB_URL=mongodb://mongo:27017/noobjs_test node npm test

License

MIT

主要指标

概览
名称与所有者madhums/node-express-mongoose-demo
主编程语言JavaScript
编程语言JavaScript (语言数: 6)
平台
许可证MIT License
所有者活动
创建于2011-03-05 08:52:32
推送于2024-12-06 07:46:15
最后一次提交
发布数2
最新版本名称v2.0 (发布于 )
第一版名称v1.0 (发布于 )
用户参与
星数5.1k
关注者数187
派生数1.4k
提交数882
已启用问题?
问题数166
打开的问题数1
拉请求数165
打开的拉请求数11
关闭的拉请求数87
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?