Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/madhums/node-express-mongoose-demo
A simple demo app using node and mongodb for beginners (with docker)
https://github.com/madhums/node-express-mongoose-demo
demo docker express mongodb mongoose node passport pug
Last synced: 4 days ago
JSON representation
A simple demo app using node and mongodb for beginners (with docker)
- Host: GitHub
- URL: https://github.com/madhums/node-express-mongoose-demo
- Owner: madhums
- License: mit
- Created: 2011-03-05T08:52:32.000Z (almost 14 years ago)
- Default Branch: main
- Last Pushed: 2024-09-21T10:32:21.000Z (4 months ago)
- Last Synced: 2024-10-29T14:51:22.449Z (3 months ago)
- Topics: demo, docker, express, mongodb, mongoose, node, passport, pug
- Language: JavaScript
- Homepage: https://nodejs-express-demo.fly.dev
- Size: 3.61 MB
- Stars: 5,122
- Watchers: 190
- Forks: 1,378
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-github-repos - madhums/node-express-mongoose-demo - A simple demo app using node and mongodb for beginners (with docker) (JavaScript)
README
[![tests](https://github.com/madhums/node-express-mongoose-demo/actions/workflows/test.yml/badge.svg)](https://github.com/madhums/node-express-mongoose-demo/actions/workflows/test.yml)
# 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](#boilerplate)
- [Install](#install)
- [Tests](#tests)
- [Docker](#docker)
- [License](#license)## Boilerplate
Want to build something from scratch? use the [boilerplate](https://github.com/madhums/node-express-mongoose)
* Checkout the [apps that are built using this approach](https://github.com/madhums/node-express-mongoose/wiki/Apps-built-using-this-approach)
* The [wiki](https://github.com/madhums/node-express-mongoose/wiki) is wip, it has some information about the way application is setup.## Install
```sh
git clone git://github.com/madhums/node-express-mongoose-demo.git
npm install
cp .env.example .env
npm start
```Then visit [http://localhost:3000/](http://localhost:3000/)
**NOTE:** Do not forget to set the twitter, google, linkedin and github `CLIENT_ID`s and `SECRET`s. 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](https://devcenter.heroku.com/articles/config-vars).
## Tests
```sh
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.
```sh
npm i
cp .env.example .env
```Start the services
```sh
docker-compose up -d
```View the logs
```sh
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
```sh
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
```sh
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