Skip to content

Commit

Permalink
base commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMartinDev committed Nov 19, 2021
0 parents commit ad388a2
Show file tree
Hide file tree
Showing 23 changed files with 20,262 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
LOGGER_LEVEL=debug
MONITORING_INTERVAL=60000 # 1 minute
DATABASE_TYPE=sqlite

# DATABASE_HOST=
# DATABASE_PORT=
# DATABASE_USER=
# DATABASE_PASSWORD=
# DATABASE_NAME=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
data/*
public/*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:16

WORKDIR /app
RUN chown node:node /app
USER node

RUN apt-get install curl && \
curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash && \
apt-get install speedtest

COPY ./package*.json ./

ENV NODE_ENV=production

RUN npm ci

COPY . .

CMD ["npm", "start"]
Binary file added NetworkStats.paw
Binary file not shown.
9 changes: 9 additions & 0 deletions client/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div>
Hello world!
</div>
</template>

<script setup>
console.log('Hello world!')
</script>
5 changes: 5 additions & 0 deletions client/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createApp } from "vue";

import App from './App.vue';

createApp(App).mount("#app");
13 changes: 13 additions & 0 deletions client/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app"></div>
<script src="{{baseURL}}/js/app.js"></script>
</body>
</html>
66 changes: 66 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
require('dotenv').config();

const convict = require('convict');

const LOGGER_LEVELS = Object.keys(require('pino')()?.levels?.values);

convict.addFormat(require('convict-format-with-validator').ipaddress);

const config = convict({
env: {
doc: 'The application environment.',
format: ['production', 'development'],
default: 'development',
env: 'NODE_ENV'
},
logger: {
level: {
doc: 'The minimum logger level to be logged',
format: LOGGER_LEVELS,
default: 'debug',
env: 'LOGGER_LEVEL',
},
},
monitoring: {
interval: {
doc: 'The time between two speedtests in milliseconds.',
format: Number,
default: 30000, // 30 seconds
env: 'MONITORING_INTERVAL',
},
},
database: {
type: {
default: 'sqlite',
doc: 'The database type.',
format: ['mysql', 'postgresql', 'sqlite'],
env: 'DATABASE_TYPE',
},
host: {
format: 'ipaddress',
env: 'DATABASE_HOST',
},
port: {
format: 'port',
env: 'DATABASE_PORT',
},
user: {
env: 'DATABASE_USER',
format: '*',
},
password: {
env: 'DATABASE_PASSWORD',
format: '*',
sensitive: true,
},
database: {
default: 'network_stats',
env: 'DATABASE_NAME',
format: '*',
},
},
});

config.validate({ allowed: 'strict' });

module.exports = config;
14 changes: 14 additions & 0 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Update with your config settings.

module.exports = {
development: {
migrations: {
tableName: 'knex_migrations'
}
},
production: {
migrations: {
tableName: 'knex_migrations'
}
},
};
21 changes: 21 additions & 0 deletions migrations/20211117192523_create_network_stats_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

module.exports = {
up: async (knex) => {
const exists = await knex.schema.hasTable('network_stats');

if (exists) {
return;
}

return knex.schema.createTable('network_stats', (t) => {
t.increments('id').primary();
t.float('upload').notNullable();
t.float('download').notNullable();
t.float('ping').notNullable();
t.datetime('created_at').defaultTo(knex.fn.now());
});
},
down: (knex) =>{
return knex.schema.dropTableIfExists('network_stats');
},
};
Loading

0 comments on commit ad388a2

Please sign in to comment.