-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from ogs-at-usi/develop
Milestone 1
- Loading branch information
Showing
47 changed files
with
4,814 additions
and
9,283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
env: | ||
browser: true | ||
commonjs: true | ||
es2021: true | ||
node: true | ||
extends: [standard, prettier] | ||
root: true | ||
overrides: [] | ||
ignorePatterns: [ "views.js" ] | ||
parserOptions: | ||
ecmaVersion: latest | ||
rules: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# ESLint is a tool for identifying and reporting on patterns | ||
# found in ECMAScript/JavaScript code. | ||
# More details at https://github.com/eslint/eslint | ||
# and https://eslint.org | ||
|
||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
pull_request: | ||
branches: | ||
- main | ||
- develop | ||
|
||
jobs: | ||
code-style: | ||
name: Run style checks | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
node-version: [ 14 ] | ||
|
||
permissions: | ||
contents: read | ||
security-events: write | ||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: yarn | ||
|
||
- name: Install packages | ||
run: yarn | ||
|
||
- name: Run ESLint | ||
run: yarn run style:lint | ||
|
||
- name: Run Prettier | ||
run: yarn run style:prettier | ||
|
||
testing: | ||
name: Run tests | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
node-version: [ 14 ] | ||
mongodb-version: [ 4.6 ] | ||
|
||
permissions: | ||
contents: read | ||
security-events: write | ||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Initialize environment variables | ||
run: cp -n ${GITHUB_WORKSPACE}/env.template ${GITHUB_WORKSPACE}/.env | ||
|
||
- name: Start MongoDB | ||
uses: supercharge/mongodb-github-action@docker-network | ||
with: | ||
mongodb-port: 27017 | ||
mongodb-db: handshake | ||
|
||
- name: Install packages | ||
run: yarn | ||
|
||
- name: Run tests | ||
run: yarn run start:test | ||
env: | ||
MONGODB_URI: mongodb://localhost:27017/handshake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require: should | ||
R: spec | ||
ui: bdd | ||
trace-warnings: true | ||
exit: true | ||
timeout: 15000 | ||
reporter: spec | ||
recursive: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
parser: babel | ||
printWidth: 80 | ||
singleQuote: true | ||
tabWidth: 2 | ||
trailingComma: es5 | ||
useTabs: false | ||
semi: true | ||
arrowParens: always | ||
bracketSpacing: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,60 @@ | ||
|
||
|
||
|
||
//require framework and middleware dependencies | ||
// require framework and middleware dependencies | ||
const express = require('express'); | ||
const path = require('path'); | ||
const logger = require('morgan'); | ||
const methodOverride = require('method-override'); | ||
const multer = require('multer'); | ||
|
||
const multer = require('multer'); | ||
const ejsc = require('ejsc-views'); | ||
const cookieParser = require('cookie-parser'); | ||
|
||
const fs = require('fs-extra'); | ||
|
||
require('dotenv').config(); | ||
|
||
|
||
//init framework | ||
const app = express(); | ||
|
||
|
||
const initDB = require('./models'); | ||
|
||
app.use(logger('dev')); | ||
app.use(express.urlencoded({ extended: false })); // parse application/x-www-form-urlencoded | ||
app.use(express.json({limit: '4MB'})); // parse application/json | ||
app.use(multer().none()); //parse multipart/form-data | ||
|
||
app.use(express.static(path.join(__dirname, 'public'), {index: "index.html"})); | ||
app.use(express.urlencoded({ extended: false })); // parse application/x-www-form-urlencoded | ||
app.use(express.json({ limit: '4MB' })); // parse application/json | ||
app.use(multer().none()); // parse multipart/form-data | ||
app.use(cookieParser()); | ||
|
||
app.use( | ||
express.static(path.join(__dirname, 'public'), { index: 'index.html' }) | ||
); | ||
|
||
app.set('view engine', 'html'); | ||
|
||
ejsc.compile(views_dir = "views", output_dir = "public/js", details = false); | ||
|
||
//co | ||
ejsc.compile('views', 'public/js', false); | ||
|
||
// TODO - controllers | ||
|
||
app.use('/auth', require('./routes/auth')); | ||
app.use('/api', require('./routes/chat')); | ||
|
||
// TODO - add routes here | ||
|
||
//default fallback handlers | ||
// catch 404 and forward to error handler | ||
app.use(function(req, res, next) { | ||
const err = new Error('Not Found'); | ||
err.status = 404; | ||
next(err); | ||
}); | ||
|
||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.json({ | ||
message: err.message, | ||
error: err | ||
}); | ||
}); | ||
app.use(function (req, res, next) { | ||
const err = new Error('Not Found'); | ||
err.status = 404; | ||
next(err); | ||
}); | ||
|
||
app.use(function (err, req, res, _) { | ||
res.status(err.status || 500); | ||
res.json({ | ||
message: err.message, | ||
error: err, | ||
}); | ||
}); | ||
|
||
//start server | ||
// start server | ||
app.set('port', process.env.PORT || 8888); | ||
|
||
var server = require('http').createServer(app); | ||
const server = require('http').createServer(app); | ||
|
||
server.on('listening', function() { | ||
server.on('listening', function () { | ||
console.log('Express server listening on port ' + server.address().port); | ||
}); | ||
|
||
// TODO websocket server | ||
|
||
initDB(); | ||
server.listen(app.get('port')); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = Object.freeze({ | ||
JWT_COOKIE_NAME: 'JWT_TOKEN', | ||
REFRESH_COOKIE_NAME: 'REFRESH_TOKEN', | ||
JWT_MAX_AGE: 5 * 60 * 1000, | ||
REFRESH_MAX_AGE: 14 * 24 * 60 * 60 * 1000, | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.