This is a hackathon boilerplate for new Node.js applications created by Major League Hacking. It is for hackers looking to get started quickly on a new hackathon project using the Node.js environment.
This project requires the following tools:
To get started, install NPM and MongoDB Community Server on your local computer if you don't have them already. Here is a guide to install MongdoDB on any major platform (Windows, Mac, Linux)
If you're on Windows:
Follow this tutorial that would be relevant for Step 4.
Note: The tutorial's example uses version 3.4 of MongoDB, make sure you type the version that is installed on your computer. If you're not sure what version you have, you can check here:
C:\Program Files\MongoDB\Server
Step 1. Clone the code into a fresh folder
$ git clone https://github.com/MLH/mlh-hackathon-nodejs-mongodb-starter.git
$ cd mlh-hackathon-nodejs-mongodb-starter
Step 2. Install Dependencies.
Next, we need to install the project dependencies, which are listed in package.json
.
$ npm install
Step 3: Create an app on GitHub
Head over to GitHub OAuth apps and create a new OAuth app.
Under Application name, name it what you like
You'll need to specify a Homepage URL, which should be something like:
https://localhost:5000
You'll need to specify a Authorization callback URL, which should be something like:
https://localhost:5000/auth/callback/github
The default port for our app is 5000
, but you may need to update this if your setup uses a different port or if you're hosting your app somewhere besides your local machine.
Step 4: Update environment variables and run the Server.
Create a new file named .env
by duplicating .env.sample
. Update the new file with the GitHub OAuth credentials. It should look similar to this:
# .env file
MONGODB_URI="[INSERT_MONGODB_URI]"
GITHUB_CLIENT_ID="[INSERT_CLIENT_ID]"
GITHUB_CLIENT_SECRET="[INSERT_CLIENT_SECRET]"
You'll place your GitHub OAuth credentials here and your database URL. Make sure to remove the quotation marks (" "). Learn more about the required Environment Variables here.
To find your MONGODB_URI
:
mongo
and hit Enter. You should see a few lines print out.
connecting to:
, you should see a URL that starts with mongodb://
MONGODB_URI
, copy and paste the link into "[INSERT_MONGODB_URI]"
mongodb://111.1.1.1/words
, copy only mongodb://111.1.1.1/
To find your GITHUB_CLIENT_ID
and GITHUB_CLIENT_SECRET
:
GITHUB_CLIENT_ID
fieldGITHUB_CLIENT_SECRET
fieldTo get the project up and running, we need to do 2 simple things:
Launch the server:
$ mongo
Lanuch the application:
$ npm start
Open http://localhost:5000 to view it in your browser.
The app will automatically reload if you make changes to the code. You will see the build errors and warnings in the console.
We enforce a Code of Conduct for all maintainers and contributors of this Guide. Read more in CONDUCT.md.
The Hackathon Starter Kit is open source software licensed as MIT.