mirror of
https://github.com/Leahnaya/Sonataria-Server.git
synced 2026-04-26 09:34:16 -05:00
Adding Project To Repository
This commit is contained in:
parent
887637fe03
commit
f538209ba9
12
.editorconfig
Normal file
12
.editorconfig
Normal 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
16
.eslintrc.json
Normal 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
8
.gitignore
vendored
Normal 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
23
client/.eslintrc.json
Normal 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": {
|
||||
}
|
||||
}
|
||||
5
client/Components/AdminConsole.jsx
Normal file
5
client/Components/AdminConsole.jsx
Normal 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
6
client/mainapp.jsx
Normal 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
6841
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
package.json
Normal file
35
package.json
Normal 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
38
public/bundle.js
Normal file
File diff suppressed because one or more lines are too long
7
public/bundle.js.map
Normal file
7
public/bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
12
public/index.html
Normal file
12
public/index.html
Normal 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
9
server/config.js
Normal 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
17
server/index.js
Normal 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
34
server/router.js
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user