Skip to content

Commit a8e8325

Browse files
author
Danielson
committed
updated files to include ES6 features
1 parent 56f93a5 commit a8e8325

File tree

3,089 files changed

+314978
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,089 files changed

+314978
-4
lines changed

.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"program": "${workspaceRoot}\\app.js"
12+
},
13+
{
14+
"type": "node",
15+
"request": "attach",
16+
"name": "Attach to Port",
17+
"address": "localhost",
18+
"port": 5858
19+
}
20+
]
21+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
}

LICENSE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
MIT License
2-
31
Copyright (c) 2017 CreativeBitStudio
42

53
Permission is hereby granted, free of charge, to any person obtaining a copy

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
# node_express_app
2-
A simple node and express app with ES6 features to get you started in modern web development and practice.
1+
Developed for CreativeBitStudio by our very own full stack developer Daniel C.
2+
3+
4+
Welcome to another CreativeBitStudio tutorial.
5+
An express-node app with Pug.
6+
7+
This app contains all the necessary modules to develop a simple express app to play around and test with. All the way to installing the express-generator to publish a fully functional web application.
8+
9+
Technologies used
10+
11+
Express 4.0
12+
Npm 4.1.1
13+
Node 6.9.0
14+
Pug 2.0.0 beta (can be downgraded to 2.0.0, simply)
15+
16+
List of all dependencies are shown in the package.json file
17+
18+
Nodemon is saved under development dependencies and is used to restart the server automatically anytime a change is made to the application. To start the server, simply type the command: nodemon app.
19+
20+
Note: each file is commented explaining what each piece of code does.
21+
22+
ENJOY!!
23+
24+
Feedback: creativebitstudio@gmail.com
25+
Hire us: info@creativebitstudio.com

app.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// in the following we are declaring and requiring all necessary node modules
2+
const http = require('http')
3+
const express = require('express'); // used to create an express application
4+
const path = require('path');
5+
const favicon = require('serve-favicon');
6+
const bodyParser = require('body-parser');
7+
const index = require('./routes/index');
8+
9+
// calling the express function declared previously
10+
const app = express();
11+
12+
// an application property that assigns a name (port) and a return value
13+
//(the return value is whatever is in the enviornment port, if known, then return port 3000)
14+
app.set('port', process.env.PORT || 3000)
15+
16+
// sets the name and value of the template engine
17+
// in this case we are indicating which path to follow on the root folder, and that it is a PUG view engine.
18+
app.set('views', path.join(__dirname, 'views'));
19+
app.set('view engine', 'pug');
20+
21+
// used to show a favicon of choice on the tab bar
22+
app.use(favicon(path.join(__dirname, 'public', 'node.ico')));
23+
24+
app.use(bodyParser.json());
25+
app.use(bodyParser.urlencoded({ extended: false }));
26+
app.use(express.static(path.join(__dirname, 'public')));
27+
28+
29+
// Mounts the specified middleware function or functions at the specified path:
30+
//the middleware function is executed when the base of the requested path matches path.
31+
// Simply put it tells the program where to find the index file from the root folder
32+
app.use('/', index);
33+
34+
35+
// catch 404 and forward to error handler, upgraded to ES6 standards
36+
app.use((req, res, next) => {
37+
var err = new Error('Not Found');
38+
err.status = 404;
39+
next(err);
40+
});
41+
42+
// error handler
43+
// Will also display an error page, which can be customized by adding some simple hmtl and css
44+
// under the views (error.pug) and public (style.css) folder
45+
app.use((err, req, res, next) => {
46+
// set locals, only providing error in development
47+
res.locals.message = err.message;
48+
res.locals.error = req.app.get('env') === 'development' ? err : {};
49+
50+
// render the error page
51+
res.status(err.status || 500);
52+
res.render('error');
53+
});
54+
55+
// to access the server through available port
56+
const server = http.createServer(app)
57+
server.listen(app.get('port'), () => {
58+
console.log('Express server listening on port ' + app.get('port'))
59+
})
60+
61+
// a module that will export the app
62+
module.exports = app;

node_modules/.bin/acorn

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/acorn.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/cleancss

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/cleancss.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/ecstatic

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)