Skip to content

Commit f4320d5

Browse files
Created an initial boilerplate for the project (#1)
initial boilerplate for the project_1
1 parent c45dcfa commit f4320d5

File tree

13 files changed

+3770
-2
lines changed

13 files changed

+3770
-2
lines changed

.gitignore

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Node template
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
11+
# Diagnostic reports (https://nodejs.org/api/report.html)
12+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13+
14+
# Runtime data
15+
pids
16+
*.pid
17+
*.seed
18+
*.pid.lock
19+
20+
# Directory for instrumented libs generated by jscoverage/JSCover
21+
lib-cov
22+
23+
# Coverage directory used by tools like istanbul
24+
coverage
25+
*.lcov
26+
27+
# nyc test coverage
28+
.nyc_output
29+
30+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
31+
.grunt
32+
33+
# Bower dependency directory (https://bower.io/)
34+
bower_components
35+
36+
# node-waf configuration
37+
.lock-wscript
38+
39+
# Compiled binary addons (https://nodejs.org/api/addons.html)
40+
build/Release
41+
42+
# Dependency directories
43+
node_modules/
44+
jspm_packages/
45+
46+
# Snowpack dependency directory (https://snowpack.dev/)
47+
web_modules/
48+
49+
# TypeScript cache
50+
*.tsbuildinfo
51+
52+
# Optional npm cache directory
53+
.npm
54+
55+
# Optional eslint cache
56+
.eslintcache
57+
58+
# Microbundle cache
59+
.rpt2_cache/
60+
.rts2_cache_cjs/
61+
.rts2_cache_es/
62+
.rts2_cache_umd/
63+
64+
# Optional REPL history
65+
.node_repl_history
66+
67+
# Output of 'npm pack'
68+
*.tgz
69+
70+
# Yarn Integrity file
71+
.yarn-integrity
72+
73+
# dotenv environment variables file
74+
.env
75+
.env.test
76+
77+
# parcel-bundler cache (https://parceljs.org/)
78+
.cache
79+
.parcel-cache
80+
81+
# Next.js build output
82+
.next
83+
84+
# Nuxt.js build / generate output
85+
.nuxt
86+
dist
87+
88+
# Gatsby files
89+
.cache/
90+
# Comment in the public line in if your project uses Gatsby and not Next.js
91+
# https://nextjs.org/blog/next-9-1#public-directory-support
92+
# public
93+
94+
# vuepress build output
95+
.vuepress/dist
96+
97+
# Serverless directories
98+
.serverless/
99+
100+
# FuseBox cache
101+
.fusebox/
102+
103+
# DynamoDB Local files
104+
.dynamodb/
105+
106+
# TernJS port file
107+
.tern-port
108+
109+
# Stores VSCode versions used for testing VSCode extensions
110+
.vscode-test
111+
112+
# yarn v2
113+
114+
.yarn/cache
115+
.yarn/unplugged
116+
.yarn/build-state.yml
117+
.pnp.*
118+
119+
# Jetbrains IDE files
120+
.idea
121+
122+
# VSCode files
123+
.vscode

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
# website-template
2-
A template to create all public facing sites
1+
# Website Backend
2+
3+
## Steps
4+
- Clone the repository
5+
- Navigate into the repo
6+
7+
## Running the project
8+
```shell script
9+
$ npm install
10+
$ npm start
11+
```

app.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const createError = require('http-errors')
2+
const express = require('express')
3+
const cookieParser = require('cookie-parser')
4+
const morgan = require('morgan')
5+
const boom = require('express-boom')
6+
const helmet = require('helmet')
7+
const cors = require('cors')
8+
9+
// import routes
10+
const indexRouter = require('./routes/index')
11+
12+
const app = express()
13+
14+
app.use(morgan('combined'))
15+
app.use(express.json())
16+
app.use(express.urlencoded({ extended: false }))
17+
app.use(cookieParser())
18+
app.use(helmet())
19+
app.use(cors())
20+
app.use(boom())
21+
22+
app.use('/', indexRouter)
23+
24+
// catch 404 and forward to error handler
25+
app.use(function (req, res, next) {
26+
next(createError(404))
27+
})
28+
29+
// error handler
30+
app.use(function (err, req, res, next) {
31+
// set locals, only providing error in development
32+
res.locals.message = err.message
33+
res.locals.error = req.app.get('env') === 'development' ? err : {}
34+
35+
// render the error page
36+
res.status(err.status || 500)
37+
res.boom.badRequest('Invalid request')
38+
})
39+
40+
module.exports = app

config/default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
port: process.env.PORT || 3000
3+
}

config/development.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
port: process.env.PORT || 3000
3+
}

config/production.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
port: process.env.PORT || 3000
3+
}

config/staging.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
port: process.env.PORT || 3000
3+
}

config/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
port: process.env.PORT || 3000
3+
}

controllers/healthController.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Route used to get the health status of teh server
3+
*
4+
* @param req {Object} - Express request object
5+
* @param res {Object} - Express request object
6+
*/
7+
const healthCheck = (req, res) => {
8+
return res.json({
9+
uptime: process.uptime()
10+
})
11+
}
12+
13+
module.exports = {
14+
healthCheck
15+
}

0 commit comments

Comments
 (0)