Skip to content

Commit

Permalink
Merge pull request #23 from ogs-at-usi/develop
Browse files Browse the repository at this point in the history
Milestone 1
  • Loading branch information
micheledallerive authored Nov 28, 2022
2 parents 4892c07 + 3ba3935 commit 1e4e8b8
Show file tree
Hide file tree
Showing 47 changed files with 4,814 additions and 9,283 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.yml
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: {}
97 changes: 97 additions & 0 deletions .github/workflows/ci.yml
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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# secrets
.secret

# Logs
logs
*.log
Expand Down Expand Up @@ -96,13 +99,13 @@ dist
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
views.js

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus
Expand All @@ -121,6 +124,10 @@ dist

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
.vscode

# Idea
.idea

# yarn v2
.yarn/cache
Expand Down
8 changes: 8 additions & 0 deletions .mocharc.yml
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
9 changes: 9 additions & 0 deletions .prettierrc
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
42 changes: 31 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,48 @@


### Project name
HandShake

### Vision
Worried that WhatsApp will steal your data? None of your friends use Signal? Scared that Telegram will delete your account if you don't constantly use it?

### Concept
Messaging website
Then **HandShake** is the solution for you!

A brand-new messaging service that is a thousand times better than our competitors:
- it is prettier,
- it doesn't steal your data,
- it is being developed with ♡ by the ogs @ USI.

Not only you can send text messages, audio messages, pictures and videos, but you can also play games in the chat!

*"I can do that on other messaging apps!!"*

Sure, but have you ever played Breakout against your friend with the texts you sent each other? Yeah, *thought so*.
Well, you'll be able to do that, if you use HandShake!

Download **HandShake** and join millions of other users today.

### Main features
1. Login with email and password
2. Send message,to another user thanks the user name, in real time
3. Send message, to a bunch or people in a group, in real time
4. Each message has properties:
- Time has been sent showed
2. Send messages to other users, thanks to the username, in real time
3. Send messages to a group of people, in real time
4. Each message has these properties:
- Time which it has been sent
- Name of the sender(in groups)
- Read status or received status
- message can be:
- Plain text
- file (images formats, video formats, .txt, .zip
- file (images formats, video formats, .txt, .zip)
- Game
5. The chat has properties:
- Single or group
- Background Image changeble
- Backup the messages in locale
5. The chat has these properties:
- Single chat or group chat
- Changeble background Images
- Upload file
6. Game has properties:
- singleplayer or multiplayer

### Future features
- Homepage
- Aliases for users


74 changes: 31 additions & 43 deletions app.js
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'));



6 changes: 6 additions & 0 deletions constants/auth.constants.js
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,
});
Binary file added docs/ER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1e4e8b8

Please sign in to comment.