Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
basic backend setup done ✌️
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-kas committed Jun 29, 2019
1 parent b359ab1 commit a2165ff
Show file tree
Hide file tree
Showing 21 changed files with 6,508 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Backend
SERVER_PORT=1337
100 changes: 42 additions & 58 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,61 +1,45 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Desktop.ini
ehthumbs.db
Thumbs.db

# Jetbrain IDEs (WebStorm, PhpStorm, etc.) #
############################################
*.iml
*.ipr
*.iws
.idea/

# Eclipse IDE #
###############
.project
.externalToolBuilders/
.settings/

# SublimeText project files #
#############################
*.sublime-workspace
*.sublime-project

# VSCODE project files #
########################
.vscode/

# Node #
#########
node_modules
npm-debug.log

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity
*.log

# dotenv environment variables file
# Project #
###########
.env

# next.js build output
.next
local.*
coverage
1 change: 1 addition & 0 deletions backend/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "presets": ["@babel/preset-env"] }
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
36 changes: 36 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# IDE files
.idea

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# Users Environment Variables
.lock-wscript

# Runtime configuration for swagger app
config/runtime.yaml

build
20 changes: 20 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:lts-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY src ./src
COPY test ./test
COPY config ./config
COPY .babelrc ./

FROM build AS dev
COPY nodemon.json ./
CMD ["npm", "run", "dev"]

# Run unit tests with code coverage before building release image:
FROM build AS test
CMD ["npm", "test"]

FROM build AS release
COPY src/app.swagger.yaml ./src/app.swagger.yaml
CMD ["npm", "start"]
16 changes: 16 additions & 0 deletions backend/config/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const path = require('path');

module.exports = {
swagger: {
appRoot: path.join(__dirname, '../'),
swaggerFile: path.join(__dirname, '../src/app.swagger.yaml'),
basePath: '/api',
},
server: {
host: '0.0.0.0',
port: process.env.SERVER_PORT || 1337,
},
db: {
uri: process.env.DB_URI || 'mongodb://localhost:27017/app',
},
};
34 changes: 34 additions & 0 deletions backend/config/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# swagger configuration file
# See: https://github.com/swagger-api/swagger-node/blob/master/docs/configuration.md
# values in the swagger hash are system configuration for swagger-node
swagger:
fittingsDirs: [src/fittings]
defaultPipe: null
swaggerControllerPipe: swagger_controllers # defines the standard processing pipe for controllers

# values defined in the bagpipes key are the bagpipes pipes and fittings definitions
# (see https://github.com/apigee-127/bagpipes)
bagpipes:
_router:
name: swagger_router
mockMode: false
mockControllersDirs: [src/mocks]
controllersDirs: [src/controllers]

_swagger_validate:
name: swagger_validator
validateResponse: true

# pipe for all swagger-node controllers
swagger_controllers:
- onError: json_error_handler
- cors
- swagger_security
- _swagger_validate
- express_compatibility
- _router

# pipe to serve swagger (endpoint is in swagger.yaml)
swagger_raw:
name: swagger_raw
# any other values in this file are just loaded into the config for application access...
1 change: 1 addition & 0 deletions backend/config/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
5 changes: 5 additions & 0 deletions backend/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"watch": ["src", "config", "test"],
"ext": "js,yaml",
"exec": "babel-node src/app.js"
}
Loading

0 comments on commit a2165ff

Please sign in to comment.