Removed use of Node Module ESLint, generated files for Express server.
This commit is contained in:
parent
792251dada
commit
d53b54fc83
29
.eslintrc.js
29
.eslintrc.js
@ -1,29 +0,0 @@
|
||||
export default {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
4
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"double"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
};
|
41
expressjs/app.js
Normal file
41
expressjs/app.js
Normal file
@ -0,0 +1,41 @@
|
||||
var createError = require('http-errors');
|
||||
var express = require('express');
|
||||
var path = require('path');
|
||||
var cookieParser = require('cookie-parser');
|
||||
var logger = require('morgan');
|
||||
|
||||
var indexRouter = require('./routes/index');
|
||||
var usersRouter = require('./routes/users');
|
||||
|
||||
var app = express();
|
||||
|
||||
// view engine setup
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'jade');
|
||||
|
||||
app.use(logger('dev'));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/', indexRouter);
|
||||
app.use('/users', usersRouter);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
next(createError(404));
|
||||
});
|
||||
|
||||
// error handler
|
||||
app.use(function(err, req, res, next) {
|
||||
// set locals, only providing error in development
|
||||
res.locals.message = err.message;
|
||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||
|
||||
// render the error page
|
||||
res.status(err.status || 500);
|
||||
res.render('error');
|
||||
});
|
||||
|
||||
module.exports = app;
|
90
expressjs/bin/www
Executable file
90
expressjs/bin/www
Executable file
@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var app = require('../app');
|
||||
var debug = require('debug')('expressjs:server');
|
||||
var http = require('http');
|
||||
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
*/
|
||||
|
||||
var port = normalizePort(process.env.PORT || '3000');
|
||||
app.set('port', port);
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
*/
|
||||
|
||||
var server = http.createServer(app);
|
||||
|
||||
/**
|
||||
* Listen on provided port, on all network interfaces.
|
||||
*/
|
||||
|
||||
server.listen(port);
|
||||
server.on('error', onError);
|
||||
server.on('listening', onListening);
|
||||
|
||||
/**
|
||||
* Normalize a port into a number, string, or false.
|
||||
*/
|
||||
|
||||
function normalizePort(val) {
|
||||
var port = parseInt(val, 10);
|
||||
|
||||
if (isNaN(port)) {
|
||||
// named pipe
|
||||
return val;
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
// port number
|
||||
return port;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
*/
|
||||
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
var bind = typeof port === 'string'
|
||||
? 'Pipe ' + port
|
||||
: 'Port ' + port;
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
console.error(bind + ' requires elevated privileges');
|
||||
process.exit(1);
|
||||
break;
|
||||
case 'EADDRINUSE':
|
||||
console.error(bind + ' is already in use');
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "listening" event.
|
||||
*/
|
||||
|
||||
function onListening() {
|
||||
var addr = server.address();
|
||||
var bind = typeof addr === 'string'
|
||||
? 'pipe ' + addr
|
||||
: 'port ' + addr.port;
|
||||
debug('Listening on ' + bind);
|
||||
}
|
16
expressjs/package.json
Normal file
16
expressjs/package.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "expressjs",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node ./bin/www"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie-parser": "~1.4.4",
|
||||
"debug": "~2.6.9",
|
||||
"express": "~4.16.1",
|
||||
"http-errors": "~1.6.3",
|
||||
"jade": "~1.11.0",
|
||||
"morgan": "~1.9.1"
|
||||
}
|
||||
}
|
8
expressjs/public/stylesheets/style.css
Normal file
8
expressjs/public/stylesheets/style.css
Normal file
@ -0,0 +1,8 @@
|
||||
body {
|
||||
padding: 50px;
|
||||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #00B7FF;
|
||||
}
|
9
expressjs/routes/index.js
Normal file
9
expressjs/routes/index.js
Normal file
@ -0,0 +1,9 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', function(req, res, next) {
|
||||
res.render('index', { title: 'Express' });
|
||||
});
|
||||
|
||||
module.exports = router;
|
9
expressjs/routes/users.js
Normal file
9
expressjs/routes/users.js
Normal file
@ -0,0 +1,9 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET users listing. */
|
||||
router.get('/', function(req, res, next) {
|
||||
res.send('respond with a resource');
|
||||
});
|
||||
|
||||
module.exports = router;
|
6
expressjs/views/error.jade
Normal file
6
expressjs/views/error.jade
Normal file
@ -0,0 +1,6 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
h1= message
|
||||
h2= error.status
|
||||
pre #{error.stack}
|
5
expressjs/views/index.jade
Normal file
5
expressjs/views/index.jade
Normal file
@ -0,0 +1,5 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
h1= title
|
||||
p Welcome to #{title}
|
7
expressjs/views/layout.jade
Normal file
7
expressjs/views/layout.jade
Normal file
@ -0,0 +1,7 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title= title
|
||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||
body
|
||||
block content
|
1585
package-lock.json
generated
1585
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "audioshowkit",
|
||||
"version": "1.0.0",
|
||||
"description": "A music based website styling toolkit.",
|
||||
"main": "audioshowkit.js",
|
||||
"devDependencies": {
|
||||
"eslint": "^8.11.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://dev.sys.reslate.xyz/git/ydeng/AudioShowKit.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
export default function VisualizerCore(mediaSource, fftSize = 1024) {
|
||||
function VisualizerCore(mediaSource, fftSize = 1024) {
|
||||
this._stream = mediaSource;
|
||||
this._analyzing = false;
|
||||
this._updateListeners = [];
|
||||
@ -46,7 +46,6 @@ export default function VisualizerCore(mediaSource, fftSize = 1024) {
|
||||
this._analyzing = false;
|
||||
};
|
||||
this.addUpdateListener = function (listener) {
|
||||
console.log("added listener.");
|
||||
this._updateListeners.push(listener);
|
||||
};
|
||||
this.getNumberOfBins = function () {
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
export default function bindHorizontalBar(canvasElement, visualizerCore) {
|
||||
function bindHorizontalBar(canvasElement, visualizerCore) {
|
||||
let _width = canvasElement.width;
|
||||
let _height = canvasElement.height;
|
||||
let _canvasCtx = canvasElement.getContext("2d");
|
||||
@ -9,7 +9,6 @@ export default function bindHorizontalBar(canvasElement, visualizerCore) {
|
||||
_canvasCtx.clearRect(0, 0, _width, _height); // clear canvas.
|
||||
let barWidth = Math.floor(_width / bins.length) - 1; // -1 for 1 pixel gap between bars.
|
||||
let barIndex = 0;
|
||||
console.log("updating visuals.." + barWidth);
|
||||
bins.forEach(bin => {
|
||||
let normalBin = bin / 255.0;
|
||||
_canvasCtx.fillStyle = "rgb(" + 0 + "," + bin + "," + bin + ")";
|
||||
|
@ -7,7 +7,11 @@
|
||||
<title>AudioShowKit visual test</title>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
|
||||
<script defer type="module" src='script.js'></script>
|
||||
|
||||
<script defer src="../src/VisualizerCore.js"></script>
|
||||
<script defer src="../src/patterns/HorizontalBar.js"></script>
|
||||
<script defer src='script.js'></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -1,8 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
import bindHorizontalBar from "../src/patterns/HorizontalBar.js";
|
||||
import VisualizerCore from "../src/VisualizerCore.js";
|
||||
|
||||
// We will see if the visualizers core and event systems are working correctly.
|
||||
let startBtn = document.getElementById("startbtn");
|
||||
startBtn.addEventListener("click", async (ev) => {
|
||||
@ -13,7 +10,6 @@ startBtn.addEventListener("click", async (ev) => {
|
||||
coreAndEventCanvas.width = 640;
|
||||
coreAndEventCanvas.height = 200;
|
||||
|
||||
console.log("starting playthrough.");
|
||||
mediaStream.play();
|
||||
visCore.analyze();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user