Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
josu98 committed Dec 1, 2021
0 parents commit ba9c16f
Show file tree
Hide file tree
Showing 113 changed files with 31,636 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/content-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: content-api

# This workflow is triggered on push to the 'content-web' directory of the main branch of the repository
on:
push:
branches:
- main
paths:
- 'content-api/**'

# Configure workflow to also support triggering manually
workflow_dispatch:

# Environment variables are defined so that they can be used throughout the job definitions.
env:
imageRepository: 'content-api'
resourceGroupName: 'Fabmedical-[SHORT_SUFFIX]'
containerRegistryName: 'fabmedical[SHORT_SUFFIX]'
containerRegistry: 'fabmedical[SHORT_SUFFIX].azurecr.io'
dockerfilePath: './content-api'
tag: '${{ github.run_id }}'

# Jobs define the actions that take place when code is pushed to the main branch
jobs:

build-and-publish-docker-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@master

- name: Build and push an image to container registry
uses: docker/build-push-action@v1
with:
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
path: ${{ env.dockerfilePath }}
dockerfile: '${{ env.dockerfilePath }}/Dockerfile'
registry: ${{ env.containerRegistry }}
repository: ${{ env.imageRepository }}
tags: ${{ env.tag }},latest
42 changes: 42 additions & 0 deletions .github/workflows/content-init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: content-init

# This workflow is triggered on push to the 'content-web' directory of the main branch of the repository
on:
push:
branches:
- main
paths:
- 'content-init/**'

# Configure workflow to also support triggering manually
workflow_dispatch:

# Environment variables are defined so that they can be used throughout the job definitions.
env:
imageRepository: 'content-init'
resourceGroupName: 'Fabmedical-[SHORT_SUFFIX]'
containerRegistryName: 'fabmedical[SHORT_SUFFIX]'
containerRegistry: 'fabmedical[SHORT_SUFFIX].azurecr.io'
dockerfilePath: './content-init'
tag: '${{ github.run_id }}'

# Jobs define the actions that take place when code is pushed to the main branch
jobs:

build-and-publish-docker-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@master

- name: Build and push an image to container registry
uses: docker/build-push-action@v1
with:
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
path: ${{ env.dockerfilePath }}
dockerfile: '${{ env.dockerfilePath }}/Dockerfile'
registry: ${{ env.containerRegistry }}
repository: ${{ env.imageRepository }}
tags: ${{ env.tag }},latest
64 changes: 64 additions & 0 deletions content-api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# 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

# 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

# dotenv environment variables file
.env

# next.js build output
.next

64 changes: 64 additions & 0 deletions content-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# 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

# 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

# dotenv environment variables file
.env

# next.js build output
.next

19 changes: 19 additions & 0 deletions content-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:alpine AS base
RUN apk -U add curl
WORKDIR /usr/src/app
EXPOSE 3001

FROM node:argon AS build
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

FROM base AS final
WORKDIR /usr/src/app
COPY --from=build /usr/src/app .
CMD [ "npm", "start" ]
5 changes: 5 additions & 0 deletions content-api/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports.appSettings = {
db: (function(){
return process.env.MONGODB_CONNECTION || 'mongodb://localhost:27017/contentdb';
})()
};
37 changes: 37 additions & 0 deletions content-api/controllers/app.server.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const sessionController = require('./sessions.server.controller');
const speakerController = require('./speakers.server.controller');

const counters = {
stats: 0,
speakers: 0,
sessions: 0
};

function stats() {
return {
taskId: process.pid,
hostName: process.env.HOSTNAME,
pid: process.pid,
mem: process.memoryUsage(),
counters: counters,
uptime: process.uptime()
}
}

exports.speakersGet = function(req, res) {
speakerController.list({}, function(err, speakers) {
counters.speakers++;
res.json(speakers);
});
};

exports.statsGet = function(req, res) {
counters.stats++;
res.json(stats());
};
exports.sessionsGet = function(req, res) {
sessionController.list({}, function(err, sessions) {
counters.sessions++;
res.json(sessions);
});
};
14 changes: 14 additions & 0 deletions content-api/controllers/sessions.server.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mongoose = require('mongoose'),
Session = mongoose.model('Session');

exports.list = function(query, callback) {
console.log("==== Load Sessions ====");
Session.find(query).lean().exec(function(err, sessionsList) {
if (err) {
console.error(err);
callback(err);
} else {
callback(null, sessionsList);
}
});
};
13 changes: 13 additions & 0 deletions content-api/controllers/speakers.server.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require('mongoose'),
Speaker = mongoose.model('Speaker');

exports.list = function(query, callback) {
console.log("==== Load Speakers ====");
Speaker.find(query).lean().exec(function(err, speakersList) {
if (err) {
callback(err);
} else {
callback(null, speakersList);
}
});
};
58 changes: 58 additions & 0 deletions content-api/models/session.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const mongoose = require('mongoose'),
Schema = mongoose.Schema;

const SessionSchema = new Schema({
_id: {
type: String
},
abstract: {
type: String
},
date: {
type: String
},
endTime: {
type: Date
},
eventName: {
type: String
},
hidden: {
type: Boolean
},
roomID: {
type: Number
},
roomName: {
type: String
},
sessionID: {
type: Number
},
sessioncode: {
type: String
},
speakerNames: [{
type: String
}],
speakers: [{
type: String
}],
startTime: {
type: Date
},
timeSlot: {
type: Number
},
title: {
type: String
},
trackNames: [{
type: String
}],
tracks: [{
type: String
}]
});

module.exports = mongoose.model('Session', SessionSchema);
Loading

0 comments on commit ba9c16f

Please sign in to comment.