Skip to content

Commit

Permalink
Merge pull request #44 from ogs-at-usi/develop
Browse files Browse the repository at this point in the history
Milestone 2
  • Loading branch information
micheledallerive authored Dec 5, 2022
2 parents 33f9f1f + 0ee1bbd commit d4cbce5
Show file tree
Hide file tree
Showing 84 changed files with 39,014 additions and 560 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
client/
public/
36 changes: 36 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Continuous Deployment

on:
push:
branches:
- main

jobs:
build-vue:
name: Build Vue.js app
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./client

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install packages
run: yarn
- name: Build Vue.js app
run: yarn run build
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: vue-build
path: ${GITHUB_WORKSPACE}/public
- name: Deploy to GitHub Pages
uses: actions/github-script@v5
with:
folder: ${GITHUB_WORKSPACE}/public
51 changes: 45 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ on:

jobs:
code-style:
name: Run style checks
name: Run style checks for Express server

runs-on: ${{ matrix.os }}

# defaults:
# run:
# working-directory: ./

strategy:
matrix:
os: [ ubuntu-latest ]
Expand All @@ -43,22 +47,57 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Install packages
run: yarn

- name: Run ESLint
- name: Run ESLint for Express
run: yarn run style:lint

- name: Run Prettier
- name: Run Prettier for Express
run: yarn run style:prettier

code-style-vue:
name: Run style checks for Vue.js app

runs-on: ${{ matrix.os }}

defaults:
run:
working-directory: ./client

strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [ 14 ]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install packages
run: yarn

- name: Run ESLint for Vue.js
run: yarn run style:lint

- name: Run Prettier for Vue.js
run: yarn run style:prettier

testing:
name: Run tests

runs-on: ${{ matrix.os }}

# defaults:
# run:
# working-directory: ./

strategy:
matrix:
os: [ ubuntu-latest ]
Expand All @@ -80,7 +119,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Initialize environment variables
run: cp -n ${GITHUB_WORKSPACE}/env.template ${GITHUB_WORKSPACE}/.env
run: cp -n ./env.template ./.env

- name: Start MongoDB
uses: supercharge/mongodb-github-action@docker-network
Expand All @@ -94,4 +133,4 @@ jobs:
- name: Run tests
run: yarn run start:test
env:
MONGODB_URI: mongodb://localhost:27017/handshake
MONGODB_URI: mongodb://localhost:27017/handshake
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# secrets
.secret

# Express public folder is automatically generated by Vue
/public

/bin/act

# Logs
logs
*.log
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public/
client/
40 changes: 7 additions & 33 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ const express = require('express');
const path = require('path');
const logger = require('morgan');
const multer = require('multer');
const ejsc = require('ejsc-views');
const cookieParser = require('cookie-parser');
const { authenticate } = require('./middlewares/authentication.middleware');

require('dotenv').config();

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.urlencoded({ extended: false })); // parse application/x-www.js-form-urlencoded
app.use(express.json({ limit: '4MB' })); // parse application/json
app.use(multer().none()); // parse multipart/form-data
app.use(cookieParser());
Expand All @@ -23,38 +22,13 @@ app.use(

app.set('view engine', 'html');

ejsc.compile('views', 'public/js', false);

// TODO - controllers
app.use('/auth', require('./routes/auth'));
app.use('/api', require('./routes/chat'));

// TODO - add routes here
app.use('/api', authenticate, require('./routes/chat'));

app.use(function (req, res, next) {
const err = new Error('Not Found');
err.status = 404;
next(err);
// serve Vue app if no matching route is found
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'public/index.html'));
});

app.use(function (err, req, res, _) {
res.status(err.status || 500);
res.json({
message: err.message,
error: err,
});
});

// start server
app.set('port', process.env.PORT || 8888);

const server = require('http').createServer(app);

server.on('listening', function () {
console.log('Express server listening on port ' + server.address().port);
});

// TODO websocket server

initDB();
server.listen(app.get('port'));
module.exports = app;
15 changes: 15 additions & 0 deletions bin/www.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const initDB = require('../models');
const app = require('../app');
const serverSocket = require('../serverSocket');

app.set('port', process.env.PORT || 8888);

const server = require('http').createServer(app);

server.on('listening', function () {
console.log('Express server listening on port ' + server.address().port);
});

serverSocket.init(server);
initDB();
server.listen(app.get('port'));
14 changes: 14 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: ['plugin:vue/essential', '@vue/standard', 'prettier'],
parserOptions: {
parser: '@babel/eslint-parser',
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
};
23 changes: 23 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions client/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
printWidth: 80
singleQuote: true
tabWidth: 2
trailingComma: es5
useTabs: false
semi: true
arrowParens: always
bracketSpacing: true
29 changes: 29 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# client

## Project setup

```
npm install
```

### Compiles and hot-reloads for development

```
npm run serve
```

### Compiles and minifies for production

```
npm run build
```

### Lints and fixes files

```
npm run lint
```

### Customize configuration

See [Configuration Reference](https://cli.vuejs.org/config/).
3 changes: 3 additions & 0 deletions client/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@vue/cli-plugin-babel/preset'],
};
12 changes: 12 additions & 0 deletions client/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
}
}
39 changes: 39 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "rm -f ../public/*.hot-update.* && vue-cli-service serve",
"build": "vue-cli-service build",
"style:lint": "vue-cli-service lint",
"style:lint:fix": "vue-cli-service lint --fix",
"style:prettier": "prettier --check .",
"style:prettier:fix": "prettier --write ."
},
"dependencies": {
"axios": "^1.2.0",
"core-js": "^3.8.3",
"socket.io-client": "^4.5.4",
"vue": "^2.6.14",
"vue-axios": "^3.5.2",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@vue/eslint-config-standard": "^6.1.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^8.0.3",
"vue-template-compiler": "^2.6.14"
}
}
Loading

0 comments on commit d4cbce5

Please sign in to comment.