Adding Project To Repository

This commit is contained in:
Julia Butenhoff 2022-03-08 10:38:38 -06:00
parent 887637fe03
commit f538209ba9
14 changed files with 7063 additions and 0 deletions

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

16
.eslintrc.json Normal file
View File

@ -0,0 +1,16 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"standard",
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
}
}

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Don't track the content of these folders
node_modules/
# Don't track the update files
public/binaryUpdates/*.zip
# No .env files
*.env

23
client/.eslintrc.json Normal file
View File

@ -0,0 +1,23 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"standard"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}

View File

@ -0,0 +1,5 @@
import React from 'react'
export default function AdminConsole (props) {
return <p>Hello World</p>
}

6
client/mainapp.jsx Normal file
View File

@ -0,0 +1,6 @@
import React from 'react'
import reactDom from 'react-dom'
import AdminConsole from './Components/AdminConsole.jsx'
reactDom.render(<AdminConsole />, document.getElementById('root'))

6841
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

35
package.json Normal file
View File

@ -0,0 +1,35 @@
{
"name": "sna-server",
"version": "1.0.0",
"description": "Server for Sonataria",
"main": "index.js",
"type": "module",
"private": true,
"scripts": {
"devServ": "nodemon --watch server server/index.js",
"serv": "node server/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server/index.js",
"client": "esbuild --bundle --minify --target=es6 --outfile=public/bundle.js client/mainapp.jsx",
"devClient": "nodemon --watch client -e js,jsx --exec ./node_modules/.bin/esbuild --bundle --sourcemap --target=es6 --outfile=public/bundle.js client/mainapp.jsx"
},
"author": "Julia Butenhoff, Seth Berrier",
"license": "MIT",
"dependencies": {
"dotenv": "^16.0.0",
"esbuild": "^0.14.23",
"eslint-plugin-react-hooks": "^4.3.0",
"express": "^4.17.2",
"nodemon": "^2.0.15",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-react": "^7.29.2"
}
}

38
public/bundle.js Normal file

File diff suppressed because one or more lines are too long

7
public/bundle.js.map Normal file

File diff suppressed because one or more lines are too long

12
public/index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Sonataria Server</title>
</head>
<body>
<div id="root"></div>
<script src="bundle.js"></script>
</body>
</html>

9
server/config.js Normal file
View File

@ -0,0 +1,9 @@
import 'dotenv/config'
const config = {
hostName: 'localhost',
port: parseInt(process.env.port) || 3000,
maintenenceMode: false
}
export default config

17
server/index.js Normal file
View File

@ -0,0 +1,17 @@
import config from './config.js'
import Express from 'express'
import router from './router.js'
const app = new Express()
app.use((req, res, next) => {
console.log(`${req.method}: ${req.path}`)
next()
})
app.use('/data', router)
app.use(Express.static('public'))
app.listen(config.port)
console.log(`Console listening on port: ${config.port}`)

34
server/router.js Normal file
View File

@ -0,0 +1,34 @@
import config from './config.js'
import express from 'express'
import fs from 'fs'
import path from 'path'
const router = new express.Router()
// Return status information to default route
router.get('/', (req, res) => {
// Send back the config file
res.json(config)
})
router.get('/checkUpdate', (req, res) => {
const directoryPath = path.join('public', 'binaryUpdates')
// passsing directoryPath and callback function
fs.readdir(directoryPath, (err, files) => {
// handling error
if (err) {
console.error(err)
return res.status(500).json({ error: 'Failed to get update path' })
}
// listing all files using forEach
for (let i = 0; i < files.length; i++) {
const file = files[i]
if (file.toLowerCase().includes('.zip')) {
return res.json({ version: path.basename(file, '.zip'), link: `binaryUpdates/${file}` })
}
}
res.status(404).json({ error: 'Update not found' })
})
})
export default router