Skip to content

Commit 37f11f2

Browse files
committedOct 9, 2021
Initial express template with prettier and eslint
0 parents  commit 37f11f2

16 files changed

+2587
-0
lines changed
 

‎.eslintrc.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es2021": true
6+
},
7+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
8+
"parserOptions": {
9+
"ecmaVersion": 12
10+
},
11+
"rules": {
12+
"indent": ["error", 2],
13+
"linebreak-style": ["error", "unix"],
14+
"quotes": ["error", "double"],
15+
"semi": ["error", "never"]
16+
}
17+
}

‎.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
coverage
6+
*.lcov
7+
node_modules/
8+
jspm_packages/
9+
.npm
10+
.eslintcache
11+
.env
12+
.env.test
13+
.env.production
14+
.envrc

‎.markdownlint.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
MD013:
3+
line_length: 80

‎.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

‎.prettierrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"semi": false
3+
}

‎.yamllint.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length:
6+
max: 200
7+
level: warning
8+
allow-non-breakable-words: true
9+
allow-non-breakable-inline-mappings: true
10+
truthy:
11+
allowed-values: ["true", "false", "on"]

‎README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Schibbler Backend
2+
3+
This repository shall serve the code for the schibbler backend API.
4+
5+
## Deployment
6+
7+
This code is deployed to Google Cloud's App Engine from my local machine.
8+
A pipeline for testing and linting the source code is in place.
9+
A deploment pipeline might be introduced in a later stage.

‎bin/www

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env node
2+
3+
const app = require("../src/app")
4+
const bunyan = require("bunyan")
5+
const http = require("http")
6+
const config = require("config")
7+
8+
const log = require("../src/logger")("schibbler-server")
9+
const normalizePort = (portValue) => {
10+
const port = parseInt(portValue, 10)
11+
12+
if (isNaN(port)) {
13+
return portValue
14+
}
15+
16+
if (port >= 0) {
17+
return port
18+
}
19+
20+
return false
21+
}
22+
23+
const onError = (error) => {
24+
if (error.syscall !== "listen") {
25+
throw error
26+
}
27+
28+
var bind = typeof port === "string" ? "Pipe " + port : "Port " + port
29+
30+
switch (error.code) {
31+
case "EACCES":
32+
console.error(bind + " requires elevated privileges")
33+
process.exit(1)
34+
break
35+
case "EADDRINUSE":
36+
console.error(bind + " is already in use")
37+
process.exit(1)
38+
break
39+
default:
40+
throw error
41+
}
42+
}
43+
44+
const onListening = () => {
45+
const addrress = server.address()
46+
const bind =
47+
typeof addrress === "string" ? "pipe " + addrress : "port " + addrress.port
48+
log.info("Server started and Listening on " + bind)
49+
}
50+
51+
const port = normalizePort(config.get("server.port"))
52+
app.set("port", port)
53+
54+
const server = http.createServer(app)
55+
server.listen(port)
56+
server.on("error", onError)
57+
server.on("listening", onListening)

‎config/default.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
server:
2+
port: 8080
3+
logLevel: info
4+
logSrc: false

‎config/development.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
server:
2+
logLevel: debug
3+
logSrc: true

‎nodemon.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"verbose": false,
3+
"ignore": ["*.test.js", "fixtures/*", ".git", "node_modules/**/node_modules"],
4+
"env": {
5+
"NODE_ENV": "development"
6+
},
7+
"watch": ["src/", "bin/www"],
8+
"ext": "js,json,yaml,yml"
9+
}

0 commit comments

Comments
 (0)