Commit 34cfefb3 authored by Dennis Willers's avatar Dennis Willers 🏀

Init

parents
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
FROM node:12.18.1
ENV NODE_ENV=production
EXPOSE 8080
WORKDIR /app
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install --production
COPY . .
CMD [ "node", "index.js" ]
const express = require('express');
function createRouter(db) {
const router = express.Router();
// the routes are defined here
router.post('/addSpielSession', (req, res) => {
var spielname = req.body.spielname;
if (spielname.match(/^[0-9a-zA-Z]+$/) != null) {
db.query(
'INSERT INTO Spielsession (SessionName) VALUES (\"'+req.body.spielname+'\");',
(error) => {
if (error) {
console.error(error);
res.status(500).json({status: 'error'});
} else {
res.status(200).json({status: 'ok'});
}
}
);
} else {
res.status(500).json({status: 'error'});
}
});
router.get('/SpielSession', function (req, res) {
db.query(
'SELECT * FROM Spielsession',
(error, results) => {
if (error) {
console.log(error);
res.status(500).json({status: 'error'});
} else {
res.status(200).json(results);
}
}
);
});
return router;
}
module.exports = createRouter;
image: docker:latest
stages:
- build
- package
- delete
- deploy
docker-build:
stage: package
script:
- docker login hub.willers.digital -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker build -t hub.willers.digital/dennis.willers/Tabu-Middleware .
- docker push hub.willers.digital/dennis.willers/Tabu-Middleware:latest
delete-old-container:
stage: delete
image: tetraweb/php:7.1
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$STAGING_PRIVATE_KEY")
script:
- ssh root@willers.digital -p 2233 "/usr/local/bin/docker stop Tabu-Middleware"
- ssh root@willers.digital -p 2233 "/usr/local/bin/docker rm Tabu-Middleware"
- ssh root@willers.digital -p 2233 "/usr/local/bin/docker rmi -f hub.willers.digital/dennis.willers/Tabu-Middleware:latest"
only:
- master
allow_failure: true
docker-deploy:
stage: deploy
image: tetraweb/php:7.1
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$STAGING_PRIVATE_KEY")
script:
- ssh root@willers.digital -p 2233 "/usr/local/bin/docker login hub.willers.digital -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD"
- ssh root@willers.digital -p 2233 "/usr/local/bin/docker pull hub.willers.digital/dennis.willers/Tabu-Middleware:latest"
- ssh root@willers.digital -p 2233 "/usr/local/bin/docker run -d -p 3150:8080 --mount type=bind,src=/volume1/docker/tmp6,dst=/tmp --name spring-boot-docker-test-console hub.willers.digital/dennis.willers/Tabu-Middleware:latest"
only:
- master
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const mysql = require('mysql');
const events = require('./events');
const connection = mysql.createConnection({
host : '192.168.0.50',
port : '3307',
user : 'tabuApp',
password : 'Mannheim123!',
database : 'tabu'
});
connection.connect();
const port = process.env.PORT || 8080;
const app = express()
.use(cors())
.use(bodyParser.json())
.use(events(connection));
app.listen(port, () => {
console.log(`Express server listening on port ${port}`);
});
This diff is collapsed.
{
"name": "Tabu-Middleware",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"mysql": "^2.18.1"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment