Inital commit
This commit is contained in:
parent
9237890aee
commit
efb7372b33
3
.gitignore/.gitignore → .gitignore
vendored
3
.gitignore/.gitignore → .gitignore
vendored
@ -102,3 +102,6 @@ dist
|
|||||||
|
|
||||||
# TernJS port file
|
# TernJS port file
|
||||||
.tern-port
|
.tern-port
|
||||||
|
|
||||||
|
# .env file
|
||||||
|
dev.env
|
||||||
29
README.md
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# PC Rebels
|
||||||
|
To do (Add to this and use `~~content~~` to show its done)
|
||||||
|
---
|
||||||
|
- ~~Add Readme~~
|
||||||
|
- ~~Set Up init files~~
|
||||||
|
-
|
||||||
|
|
||||||
|
Set Up:
|
||||||
|
---
|
||||||
|
1. Download & install: [vscode](https://code.visualstudio.com/download) or any editor of your choice
|
||||||
|
2. Download & install: [nodejs](https://nodejs.org/en/download/) this is needed to host the website
|
||||||
|
3. Download & install: [git](https://git-scm.com/download/win) this is so we can use git from the commandline
|
||||||
|
4. Once this is done we have to init the local repo
|
||||||
|
5. In vscode use Ctrl+~ to open up a terminal and go to a directory where you want the repo to live: type in `git clone https://github.com/rayaman/pcrebels.git` **Note: This creates a folder named after the repo**
|
||||||
|
6. Next once that is done run `npm install` This will install all the node modules that we need to run the server
|
||||||
|
7. And with that everything should be stable and runnable
|
||||||
|
8. You will need to create a file called dev.env inside of the config folder. This is where we put private variables that we dont want being committed. The .gitignore file makes sure that we dont commit this file
|
||||||
|
9. Now let's test to see if things worked
|
||||||
|
- There are 2 ways to run the code
|
||||||
|
- `npm start` This is how the webhost will run our code
|
||||||
|
- `npm test ` This uses nodemon which reloads our code automatically when we make any changes and makes dev work eaiser. (Use `npm test` when you can)
|
||||||
|
10. Once you got the code running go to http://localhost:3000/ and see if something comes up.
|
||||||
|
|
||||||
|
|
||||||
|
Vscode Extensions to make working with nodejs a little eaiser
|
||||||
|
---
|
||||||
|
- https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one
|
||||||
|
- https://marketplace.visualstudio.com/items?itemName=chaliy.handlebars-preview
|
||||||
|
- https://marketplace.visualstudio.com/items?itemName=tht13.html-preview-vscode
|
||||||
2095
package-lock.json
generated
Normal file
2095
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
package.json
Normal file
30
package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "pcrebels",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "To do (Add to this and use `~~content~~` to show its done)\r ---\r - ~~Add Readme~~",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node src/index.js",
|
||||||
|
"test": "env-cmd -f ./config/dev.env nodemon src/index.js"
|
||||||
|
},
|
||||||
|
"author": "pcrebels",
|
||||||
|
"license": "ISC",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/rayaman/pcrebels.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/rayaman/pcrebels/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/rayaman/pcrebels#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"env-cmd": "^10.1.0",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"hbs": "^4.1.0",
|
||||||
|
"mongoose": "^5.9.2",
|
||||||
|
"nodemailer": "^6.4.3",
|
||||||
|
"nodemon": "^2.0.2",
|
||||||
|
"request": "^2.88.2",
|
||||||
|
"socket.io": "^2.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
15
public/index.html
Normal file
15
public/index.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>PC Rebels</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<p>Welcome! :D</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
6
src/db/mongoose.js
Normal file
6
src/db/mongoose.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
const mongoose = require("mongoose")
|
||||||
|
|
||||||
|
mongoose.connect(process.env.MONGODB, {
|
||||||
|
useNewUrlParser: true,
|
||||||
|
useCreateIndex: true
|
||||||
|
})
|
||||||
21
src/index.js
Normal file
21
src/index.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const express = require("express")
|
||||||
|
//require("./db/mongoose") // We aren't connecting to a database just yet
|
||||||
|
const app = express()
|
||||||
|
const path = require("path")
|
||||||
|
const hbs = require("hbs")
|
||||||
|
const port = process.env.PORT || 3000
|
||||||
|
// Set some directories
|
||||||
|
const publicDirectoryPath = path.join(__dirname, "./../public")
|
||||||
|
const viewsPath = path.join(__dirname, './../templates/views')
|
||||||
|
const paritalsPath = path.join(__dirname, './../templates/partials')
|
||||||
|
|
||||||
|
app.set('view engine', 'hbs') // Hbs or handlebars is a rendering engine which allows us to insert data into a .hbs file when a client requests a page and it sends it to them as a html page
|
||||||
|
app.set('views', viewsPath) // path where our .hbs files are
|
||||||
|
hbs.registerPartials(paritalsPath) // Set the partial path
|
||||||
|
app.use(express.json())
|
||||||
|
// We put our routes here
|
||||||
|
app.use(express.static(publicDirectoryPath))
|
||||||
|
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log("Web Server listening on port " + port)
|
||||||
|
})
|
||||||
3
templates/yourtemplate.handlebars.json
Normal file
3
templates/yourtemplate.handlebars.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"name": "pcrebels"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user